// AK-P21 Interim-UI (AD-28) — privacy hub (D-P21 pending). Replaces the // hand-written Phase-10 markup with ~/ui composition: self-service export // (job list + download), account deletion (existing token flow), and // permission-gated entry cards into the tenant admin sub-areas (export, // deletion, subprocessors, AVV). The export/delete/reactivate blocks stay // REAL forms with the established intent/csrf/confirmation contract so the // existing mobile-a11y smoke selectors (ui.settings.privacy.export.form, // .delete.form, .reactivate.form) keep working unchanged. import { useTranslation } from "react-i18next"; import { Form } from "react-router"; import { FeatherChevronRight, FeatherDownload, FeatherFileText, FeatherServer, FeatherShield, FeatherTrash2, FeatherUserX, } from "@subframe/core"; import type { GdprExportJobVM, PrivacyHubSectionKey, PrivacyHubVM } from "@hivegrid/view-models"; import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageIntro, PageShell } from "../shared/PageShell"; import { useLocaleFormatters } from "~/locale/format"; import { Alert } from "~/ui/components/Alert"; import { BadgeFeedback } from "~/ui/components/BadgeFeedback"; import { Button } from "~/ui/components/Button"; import { Card } from "~/ui/components/Card"; import { EmptyState } from "~/ui/components/EmptyState"; import { Loader } from "~/ui/components/Loader"; import { TextInput } from "~/ui/components/TextInput"; export type PrivacyHubActions = { readonly onOpenSection: (section: PrivacyHubSectionKey) => void; readonly onDownloadJob: (jobId: string) => void; readonly onRetry: () => void; }; const SECTION_ICONS: Record = { export: , deletion: , subprocessors: , avv: , }; function jobTone(tone: GdprExportJobVM["tone"]): React.ComponentProps["farbe"] { if (tone === "success") return "subtle-positive"; if (tone === "warning") return "subtle-warning"; if (tone === "danger") return "subtle-negative"; return "subtle-neutral"; } export function PrivacyHubPage({ vm, actions, csrf, embedded = false, }: { vm: PrivacyHubVM; actions: PrivacyHubActions; csrf?: string | null; /** Inside the Mein-Konto hub (AK-SET-01) the hub owns the header. */ embedded?: boolean; }): React.JSX.Element { const { t } = useTranslation(); const formatters = useLocaleFormatters(); if (vm.status === "idle" || vm.status === "loading") { return (
{t("settings.privacy.states.loadingDescription")}
); } if (vm.status === "error") { return (
{t("settings.privacy.states.retry")} } />
); } if (vm.status === "empty") { return (
); } const { data } = vm; return ( {embedded ? null : ( } title={t("settings.privacy.title")} subtitle={t("settings.privacy.description")} /> )} {embedded ? {t("settings.privacy.description")} : null} {data.tenantDeletionBanner ? ( ) : null} {/* Self-service export — keeps the established intent/csrf form contract. */}
{t("settings.privacy.export.title")} {t("settings.privacy.export.description")}
{csrf ? : null} {data.selfExport.canStart ? t("settings.privacy.hub.selfExport.remaining", { remaining: data.selfExport.remaining, limit: data.selfExport.limitPer24h }) : t("settings.privacy.exportJobs.rateLimit.description", { limit: data.selfExport.limitPer24h })}
{data.selfExport.recentJobs.length > 0 ? (
{t("settings.privacy.hub.selfExport.recentTitle")} {data.selfExport.recentJobs.map((job) => (
{t(`settings.privacy.exportJobs.status.${job.status}`)} {formatters.date(job.createdAt, { dateStyle: "medium", timeStyle: "short" })} {job.canDownload ? ( ) : null}
))}
) : null}
{/* Account deletion / reactivation — existing token flow, established selectors. */}
{t("settings.privacy.delete.title")} {data.userDeletion.pendingDeletion ? ( {t("settings.privacy.delete.scheduledPrefix")}{" "} {data.userDeletion.scheduledDeletionAt ? formatters.date(data.userDeletion.scheduledDeletionAt, { dateStyle: "medium", timeStyle: "short" }) : t("settings.privacy.delete.unknownDate")} . {t("settings.privacy.delete.scheduledSuffix")} ) : ( {t("settings.privacy.delete.description", { days: formatters.number(data.graceDays) })} )}
{data.userDeletion.pendingDeletion ? (
{csrf ? : null}
) : (
{csrf ? : null}
)}
{/* Tenant admin sub-areas, permission-gated by the VM. */} {data.sections.length > 0 ? (
{t("settings.privacy.hub.adminSections.title")} {t("settings.privacy.hub.adminSections.description")}
{data.sections.map((section) => (
{SECTION_ICONS[section]}
{t(`settings.privacy.hub.sections.${section}.title`)} {t(`settings.privacy.hub.sections.${section}.description`)}
))}
) : null}
); }