// AK-P21 Interim-UI (AD-28) — AVV (data processing agreement) page (D-P21 // pending). Current version card + acceptance history table + re-acceptance // dialog (S 560). The PDF download is interim-disabled because no AVV source // PDF ships in the repo yet — the button stays visible with a plain-language // interim hint so David's final D-P21 delta only swaps optics, not flow. import { useState } from "react"; import { useTranslation } from "react-i18next"; import { PrivacyBreadcrumbs } from "./PrivacyBreadcrumbs"; import { FeatherDownload, FeatherFileText } from "@subframe/core"; import type { AvvVM } from "@hivegrid/view-models"; 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 { PageIntro } from "../shared/PageShell"; import { Dialog } from "~/ui/components/Dialog"; import { EmptyState } from "~/ui/components/EmptyState"; import { Loader } from "~/ui/components/Loader"; import { Table } from "~/ui/components/Table"; import { TextInput } from "~/ui/components/TextInput"; export type AvvActions = { readonly onAccept: (fields: { signerName: string; signerRole: string }) => void | Promise; readonly onRetry: () => void; }; export function AvvPage({ vm, actions, hubHref, embedded = false, submitting = false, errorKey = null, }: { vm: AvvVM; actions: AvvActions; 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 [acceptOpen, setAcceptOpen] = useState(false); const [signerName, setSignerName] = useState(""); const [signerRole, setSignerRole] = useState(""); const [accepting, setAccepting] = 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; async function confirmAccept(): Promise { setAccepting(true); try { await actions.onAccept({ signerName: signerName.trim(), signerRole: signerRole.trim() }); setAcceptOpen(false); setSignerName(""); setSignerRole(""); } finally { setAccepting(false); } } return (
{embedded ? null : (

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

{t("settings.privacy.avv.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.avv.description")} : null} {data.needsReacceptance ? ( ) : null} {errorKey ? : null}
{t("settings.privacy.avv.current.title", { version: data.currentVersion })} {data.currentAccepted ? t("settings.privacy.avv.current.acceptedBadge") : t("settings.privacy.avv.current.openBadge")}
{data.pdfAvailable ? t("settings.privacy.avv.current.pdfHint") : t("settings.privacy.avv.current.pdfUnavailableHint")}
{!data.currentAccepted ? ( ) : null}
{t("settings.privacy.avv.history.title")} {t("settings.privacy.avv.history.description")}
{data.acceptances.length === 0 ? ( ) : (
{t("settings.privacy.avv.columns.version")}{t("settings.privacy.avv.columns.date")}{t("settings.privacy.avv.columns.signer")}{t("settings.privacy.avv.columns.role")} } > {data.acceptances.map((acceptance) => (
{acceptance.avvVersion} {acceptance.isCurrentVersion ? ( {t("settings.privacy.avv.currentBadge")} ) : null}
{formatters.date(acceptance.createdAt, { dateStyle: "medium", timeStyle: "short" })} {acceptance.signerName} {acceptance.signerRole ?? "—"}
))}
)}
(open ? undefined : setAcceptOpen(false))}>
{t("settings.privacy.avv.reaccept.title", { version: data.currentVersion })} {t("settings.privacy.avv.reaccept.description")}
setSignerName(event.target.value)} required /> setSignerRole(event.target.value)} />
); }