// AK-P3 Interim-UI (AD-28) — Notification-Settings preview screen composed from // ~/ui (A6 settings archetype). Pure presentational component: renders the // server-built NotificationSettingsVM passed as a prop; toggles run through // injected action callbacks (M014) implemented fetcher-side by the hosting // route. Final Subframe optics land as a tracked design-nachzug once David's // D-P3 ships. import { useTranslation } from "react-i18next"; import type { NotificationSettingChannel, NotificationSettingsVM } from "@hivegrid/view-models"; import { Alert } from "~/ui/components/Alert"; import { Switch } from "~/ui/components/Switch"; export type NotificationSettingsActions = { onTogglePreference: (input: { category: string; channel: NotificationSettingChannel; enabled: boolean }) => void; /** Master switch: true = turn ALL emails off (writes every category). */ onSetEmailMaster: (disableAllEmails: boolean) => void; }; export type NotificationSettingsPageProps = { vm: NotificationSettingsVM; /** Plain-text result of the last save action (null = nothing saved yet). */ saveState: { ok: boolean; errorText?: string } | null; actions: NotificationSettingsActions; }; export function NotificationSettingsPage({ vm, saveState, actions }: NotificationSettingsPageProps) { const { t } = useTranslation(); // Loading / not-ready: keep the marker so the shell + e2e see a stable surface. if (vm.status !== "ready" || !vm.data) { return
; } const { groups, allEmailsDisabled } = vm.data; return (
{/* Header: title + subtitle (0px rhythm) */}
{t("settings.notifications.heading")} {t("settings.notifications.description")}
{saveState ? (
{saveState.ok ? ( ) : ( )}
) : null} {/* Master switch: all emails off (card surface, 16px padding) */}
{t("settings.notifications.master.heading")} {t("settings.notifications.master.description")}
{/* Event types grouped per module (A6) */}
{groups.map((group) => (
{t(group.moduleLabelKey)} {group.categories.map((category) => (
{t(category.labelKey)} {t("settings.notifications.categoryDescription", { category: String(t(category.labelKey)).toLowerCase() })}
actions.onTogglePreference({ category: category.category, channel: "IN_APP", enabled })} /> actions.onTogglePreference({ category: category.category, channel: "EMAIL", enabled })} />
))}
))}
); } function ChannelToggle({ label, checked, uiId, onChange, }: { label: string; checked: boolean; uiId: string; onChange: (enabled: boolean) => void; }) { return ( ); }