// AK-P3 Interim-UI (AD-28) — topbar notifications drawer composed from ~/ui // (real Drawer, not a card fake — D07). Pure presentational: the host (NavBar) // owns the SSE subscription and open state; items arrive as VM props, clicks // follow validated deeplinks. Final Subframe optics land as a tracked // design-nachzug once David's D-P3 ships. import { useTranslation } from "react-i18next"; import type { NotificationCenterItemVM } from "@hivegrid/view-models"; import { BadgeFeedback } from "~/ui/components/BadgeFeedback"; import { Button } from "~/ui/components/Button"; import { Drawer } from "~/ui/components/Drawer"; import { EmptyState } from "~/ui/components/EmptyState"; const DRAWER_MAX_ITEMS = 10; export type NotificationsDrawerProps = { open: boolean; items: readonly NotificationCenterItemVM[]; /** Href of the full notification center route ("show all"). */ allHref: string; onClose: () => void; }; export function NotificationsDrawer({ open, items, allHref, onClose }: NotificationsDrawerProps) { const { t, i18n } = useTranslation(); const visibleItems = items.slice(0, DRAWER_MAX_ITEMS); const dateTimeFormatter = new Intl.DateTimeFormat(i18n.language, { dateStyle: "short", timeStyle: "short" }); return ( (nextOpen ? undefined : onClose())}>
{t("notifications.center.drawer.title")}
{visibleItems.length === 0 ? (
) : (
    {visibleItems.map((item) => ( ))}
)}
); } function DrawerItem({ item, formatter }: { item: NotificationCenterItemVM; formatter: Intl.DateTimeFormat }) { const { t, i18n } = useTranslation(); const messageLabel = i18n.exists(item.messageKey) ? String(t(item.messageKey)) : String(t("notifications.center.unknownMessage")); const timestampIso = item.sentAtIso ?? item.createdAtIso; const body = (
{messageLabel} {timestampIso ? formatter.format(new Date(timestampIso)) : String(t("notifications.center.timestamps.notRecorded"))}
); return (
  • {item.deeplinkHref ? ( {body} ) : ( body )} {!item.isRead ? ( {t("notifications.center.statuses.unread")} ) : null}
  • ); }