// AK-P21 Interim-UI (AD-28) — tenant deletion area (D-P21 pending). Layout and // copy adapted from David's Subframe page "S01 Settings Workspaces // Loeschbereich" (WF-P2 Konto loeschen): explanation card with the // "request, not immediate" info box, export hint, and the destructive request // action. With a pending request the page shows the grace countdown banner // with the cancel action instead. Final Subframe optics = design-nachzug. import { useState } from "react"; import { useTranslation } from "react-i18next"; import { PrivacyBreadcrumbs } from "./PrivacyBreadcrumbs"; import { FeatherCheck, FeatherDownload, FeatherInfo, FeatherShieldCheck, FeatherTrash2 } from "@subframe/core"; import type { TenantDeletionVM } from "@hivegrid/view-models"; import { useLocaleFormatters } from "~/locale/format"; import { Alert } from "~/ui/components/Alert"; import { Button } from "~/ui/components/Button"; import { Card } from "~/ui/components/Card"; import { PageIntro } from "../shared/PageShell"; import { Dialog } from "~/ui/components/Dialog"; import { EmptyState } from "~/ui/components/EmptyState"; import { Loader } from "~/ui/components/Loader"; import { TenantDeletionWizardDialog, type TenantDeletionSubmitFields } from "./TenantDeletionWizardDialog"; export type TenantDeletionActions = { readonly onRequest: (fields: TenantDeletionSubmitFields) => void; readonly onCancelRequest: (requestId: string) => void | Promise; readonly onOpenExport: () => void; readonly onRetry: () => void; }; export function TenantDeletionPage({ vm, actions, hubHref, embedded = false, submitting = false, errorKey = null, }: { vm: TenantDeletionVM; actions: TenantDeletionActions; hubHref: string; /** Inside the Compliance hub (AK-SET-01) the hub owns breadcrumb and heading. */ embedded?: boolean; submitting?: boolean; errorKey?: string | null; }): React.JSX.Element { const { t } = useTranslation(); const formatters = useLocaleFormatters(); const [wizardOpen, setWizardOpen] = useState(false); const [cancelOpen, setCancelOpen] = useState(false); const [cancelling, setCancelling] = useState(false); 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; const request = data.request; const pendingRequest = request && request.status === "pending" ? request : null; const executingRequest = request && request.status === "executing" ? request : null; async function confirmCancel(): Promise { if (!pendingRequest) return; setCancelling(true); try { await actions.onCancelRequest(pendingRequest.id); setCancelOpen(false); } finally { setCancelling(false); } } return (
{embedded ? null : (

{t("settings.privacy.deletion.title")}

{t("settings.privacy.deletion.description")}
)} {/* Full content width: the cards were capped at 720px, which left the screen looking like a narrow column with two thirds of the page empty. */}
{embedded ? {t("settings.privacy.deletion.description")} : null} {pendingRequest ? (
{t("settings.privacy.deletion.grace.requestedAt", { date: formatters.date(pendingRequest.createdAt, { dateStyle: "medium" }), })}
) : null} {executingRequest ? ( ) : null} {!pendingRequest && !executingRequest ? (
{t("settings.privacy.deletion.request.title")} {t("settings.privacy.deletion.request.description", { days: data.graceDays })}
{t("settings.privacy.deletion.request.notImmediateTitle")}
{(["grace", "cancel"] as const).map((point) => (
{t(`settings.privacy.deletion.request.point.${point}`, { days: data.graceDays })}
))}
{t("settings.privacy.deletion.request.exportTitle")} {t("settings.privacy.deletion.request.exportDescription")}
{t("settings.privacy.deletion.request.permissionNote")}
) : null}
setWizardOpen(false)} /> (open ? undefined : setCancelOpen(false))}>
{t("settings.privacy.deletion.cancelDialog.title")} {t("settings.privacy.deletion.cancelDialog.description")}
); }