POPIA toolkit part 3: retention, breach register, readiness

- Retention policies (Admin -> Privacy -> Retention) applied by a nightly
  `retention` job: inactive accounts anonymised after 5 years with a
  30-day warning (on by default; never staff roles or people with an
  upcoming registration), form answers, login history, payer details in
  payment notifications, audit/access logs
- User.lastLoginAt (set on login, backfilled) and inactivityWarnedAt
- Breach register (SecurityBreach) with drafts for the people affected
  and the Information Regulator
- Readiness checklist with a score
- Children's/medical flag in the access log; {retention} placeholder in
  the privacy notice
- Unit tests (retention.test.js), e2e (privacy-retention.spec.ts); docs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mt6TCv85T9VKRq3cV7rXq
This commit is contained in:
2026-10-23 20:25:58 +02:00
co-authored by Claude Opus 5.5
parent 7f5e31461a
commit 6907bc3bd3
32 changed files with 1441 additions and 35 deletions
@@ -47,6 +47,10 @@ const ACTIONS = [
"operator_created",
"operator_updated",
"operator_deleted",
"retention_policies_updated",
"retention_run",
"breach_recorded",
"breach_updated",
] as const;
const ACTION_LABELS: Record<string, string> = {
@@ -86,6 +90,10 @@ const ACTION_LABELS: Record<string, string> = {
operator_created: "Operator added",
operator_updated: "Operator changed",
operator_deleted: "Operator removed",
retention_policies_updated: "Retention periods changed",
retention_run: "Retention job deleted/anonymised data",
breach_recorded: "Security compromise recorded",
breach_updated: "Security compromise updated",
};
interface AuditLogEntry {
@@ -3,18 +3,24 @@
import React, { Suspense } from "react";
import Link from "next/link";
import { useRouter, useSearchParams } from "next/navigation";
import { ShieldCheck, ScrollText, Building2, ListChecks, Eye, Inbox } from "lucide-react";
import { ShieldCheck, ScrollText, Building2, ListChecks, Eye, Inbox, Gauge, Timer, AlertTriangle } from "lucide-react";
import { useAuth } from "@/hooks/useAuth";
import { BackLink } from "@/components/shared/BackLink";
import { NoticeEditor } from "@/components/admin/privacy/NoticeEditor";
import { OperatorsPanel } from "@/components/admin/privacy/OperatorsPanel";
import { ConsentLogPanel, AccessLogPanel } from "@/components/admin/privacy/LogPanels";
import { ReadinessPanel } from "@/components/admin/privacy/ReadinessPanel";
import { RetentionPanel } from "@/components/admin/privacy/RetentionPanel";
import { BreachesPanel } from "@/components/admin/privacy/BreachesPanel";
const TABS = [
{ key: "readiness", label: "Readiness", icon: Gauge },
{ key: "notice", label: "Privacy notice", icon: ScrollText },
{ key: "operators", label: "Operators", icon: Building2 },
{ key: "retention", label: "Retention", icon: Timer },
{ key: "consent", label: "Consent log", icon: ListChecks },
{ key: "access", label: "Access log", icon: Eye },
{ key: "breaches", label: "Breaches", icon: AlertTriangle },
] as const;
type TabKey = (typeof TABS)[number]["key"];
@@ -22,7 +28,7 @@ function PrivacyAdmin() {
const { token } = useAuth();
const router = useRouter();
const params = useSearchParams();
const tab = (TABS.find(t => t.key === params.get("tab"))?.key || "notice") as TabKey;
const tab = (TABS.find(t => t.key === params.get("tab"))?.key || "readiness") as TabKey;
return (
<div className="max-w-5xl mx-auto w-full">
@@ -53,10 +59,13 @@ function PrivacyAdmin() {
{token && (
<div className="border rounded-xl p-5 bg-white shadow-sm">
{tab === "readiness" && <ReadinessPanel token={token} />}
{tab === "notice" && <NoticeEditor token={token} />}
{tab === "operators" && <OperatorsPanel token={token} />}
{tab === "retention" && <RetentionPanel token={token} />}
{tab === "consent" && <ConsentLogPanel token={token} />}
{tab === "access" && <AccessLogPanel token={token} />}
{tab === "breaches" && <BreachesPanel token={token} />}
</div>
)}
</div>