// 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 { FeatherBell, FeatherLock } from "@subframe/core"; import type { NotificationSettingChannel, NotificationSettingsVM } from "@hivegrid/view-models"; import { Alert } from "~/ui/components/Alert"; import { Card } from "~/ui/components/Card"; import { Switch } from "~/ui/components/Switch"; import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageIntro, PageShell } from "../shared/PageShell"; 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; /** Inside the Mein-Konto hub (AK-SET-01) the hub owns the header. */ embedded?: boolean; }; export function NotificationSettingsPage({ vm, saveState, actions, embedded = false }: 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 ( {embedded ? null : ( } title={t("settings.notifications.heading")} subtitle={t("settings.notifications.description")} /> )} {null} ); } const { groups, allEmailsDisabled } = vm.data; return ( {embedded ? null : ( } title={t("settings.notifications.heading")} subtitle={t("settings.notifications.description")} /> )}
{embedded ? {t("settings.notifications.description")} : null} {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)} {category.locked ? t("settings.notifications.lockedDescription") : t("settings.notifications.categoryDescription", { category: t(category.labelKey) })}
{category.locked ? ( {t("settings.notifications.alwaysOn")} ) : (
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 ( ); }