Privacy notice: built-in text up to date, review flow, acceptance (1.48.1)

The built-in notice now covers volunteer rosters, event series, season
passes, webhooks, how people agree to it, and the provider-notices
storage item. Sites with their own published version see what changed
in the editor (sections marked, use new text per section or all, add
missing sections, "Done - hide this"). Account activation asks for
agreement to the terms and notice; anyone who never accepted is asked
once after login. The cookie button shows above any cookie section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-28 13:15:57 +02:00
co-authored by Claude Opus 5.5
parent aa79168660
commit adb6e11000
27 changed files with 368 additions and 44 deletions
@@ -1,5 +1,6 @@
"use client";
import React, { Suspense, useMemo, useState } from "react";
import Link from "next/link";
import { Navbar } from "@/components/layout/Navbar";
import { Footer } from "@/components/layout/Footer";
import { apiFetch } from "@/lib/api";
@@ -16,8 +17,11 @@ function ActivateAccountContent() {
const [confirm, setConfirm] = useState("");
const [status, setStatus] = useState<string | null>(null);
const [loading, setLoading] = useState(false);
// An account made for them (by staff, at the door, or by whoever registered them): they agree
// to the terms and privacy notice here, as at sign-up.
const [accepted, setAccepted] = useState(false);
const canSubmit = useMemo(() => password.length >= 8 && password === confirm && !!token, [password, confirm, token]);
const canSubmit = useMemo(() => password.length >= 8 && password === confirm && !!token && accepted, [password, confirm, token, accepted]);
const submit = async (e: React.FormEvent) => {
e.preventDefault();
@@ -25,7 +29,7 @@ function ActivateAccountContent() {
try {
setLoading(true);
setStatus(null);
const data = await apiFetch<{ token?: string }>("/api/users/activate", { method: "POST", body: { token, password } });
const data = await apiFetch<{ token?: string }>("/api/users/activate", { method: "POST", body: { token, password, acceptTerms: accepted } });
// Auto-login: save the session token (under the key AuthContext reads) and load the
// dashboard fresh so the new session is picked up.
if (data?.token) saveToken(data.token);
@@ -64,6 +68,14 @@ function ActivateAccountContent() {
{password && confirm && password !== confirm && (
<p className="text-xs text-red-600">Passwords do not match.</p>
)}
<div className="flex items-start gap-2">
<input id="terms" type="checkbox" checked={accepted} onChange={e => setAccepted(e.target.checked)} className="mt-1 h-4 w-4 border-gray-300 rounded accent-brand-600" required />
<label htmlFor="terms" className="text-sm text-gray-700 leading-snug">
I confirm that I&apos;ve read and agree to the{" "}
<Link href="/legal/terms" target="_blank" className="text-brand-600 hover:underline">Terms of Use</Link> and{" "}
<Link href="/legal/privacy" target="_blank" className="text-brand-600 hover:underline">Privacy Policy</Link>.
</label>
</div>
<button disabled={loading || !canSubmit} className="px-4 py-2 rounded bg-brand-600 hover:bg-brand-700 text-white disabled:opacity-60 w-full py-2.5 font-medium">
{loading ? "Activating…" : "Activate my account"}
</button>
@@ -24,6 +24,7 @@ type Msg = { type: "ok" | "err"; text: string } | null;
const SOURCE_LABEL: Record<string, string> = {
signup: "when you signed up",
activation: "when you activated your account",
privacy_centre: "in your privacy settings",
prompt: "when we asked after logging in",
unsubscribe_link: "with an unsubscribe link",
@@ -28,7 +28,7 @@ type ParentalRow = { id: string; at: string | null; child: string; event: string
type LogResponse<T> = { rows: T[]; total: number; pageSize: number };
const SOURCE: Record<string, string> = {
signup: "Sign-up", privacy_centre: "Privacy page", prompt: "Asked after login", unsubscribe_link: "Unsubscribe link",
signup: "Sign-up", activation: "Account activation", privacy_centre: "Privacy page", prompt: "Asked after login", unsubscribe_link: "Unsubscribe link",
whatsapp_stop: "Replied STOP", existing_account: "Existing account (1.38.0)", admin: "Administrator",
};
@@ -2,13 +2,15 @@
import React, { useCallback, useEffect, useState } from "react";
import Link from "next/link";
import { ArrowUp, ArrowDown, Trash2, Plus, RotateCcw, Eye, PencilLine } from "lucide-react";
import { ArrowUp, ArrowDown, Trash2, Plus, RotateCcw, Eye, PencilLine, Sparkles } from "lucide-react";
import { apiFetch } from "@/lib/api";
import { errorMessage } from "@/lib/utils";
import { PrivacyNoticeSection, type NoticeSection } from "@/components/shared/PrivacyNoticeSection";
type Version = { version: number; publishedAt: string; changeSummary: string | null; requiresAcceptance: boolean; publishedBy: string | null; acceptances: number };
type Draft = { sections: NoticeSection[]; rendered: NoticeSection[]; isDraft: boolean; savedAt: string | null; versions: Version[]; builtIn: NoticeSection[] };
// Changes to the built-in text since this site last reviewed them (only once it has published its own).
type BuiltInUpdate = { revision: string; summary: string[]; sections: string[] };
type Draft = { sections: NoticeSection[]; rendered: NoticeSection[]; isDraft: boolean; savedAt: string | null; versions: Version[]; builtIn: NoticeSection[]; builtInUpdates?: BuiltInUpdate[] };
type Msg = { type: "ok" | "err"; text: string } | null;
const PLACEHOLDER_HELP: [string, string][] = [
@@ -106,10 +108,45 @@ export function NoticeEditor({ token }: { token: string }) {
}
};
// The built-in text changed since this site last looked: hide the list once the admin has been through it.
const markReviewed = async () => {
setBusy(true);
try {
await apiFetch("/api/privacy/notice/builtin-reviewed", { method: "POST", authToken: token });
setDraft(d => (d ? { ...d, builtInUpdates: [] } : d));
setMsg({ type: "ok", text: "Done. Remember to save the draft and publish if you took any new text." });
} catch (e) {
setMsg({ type: "err", text: errorMessage(e) || "Could not save." });
} finally {
setBusy(false);
}
};
if (!draft) return msg ? <p className="text-sm text-red-700">{msg.text}</p> : <p className="text-sm text-gray-400">Loading…</p>;
const builtInById = new Map(draft.builtIn.map(s => [s.id, s]));
const current = draft.versions[0];
const updates = draft.builtInUpdates || [];
const updatedIds = new Set(updates.flatMap(u => u.sections));
const differs = (s: NoticeSection) => { const b = builtInById.get(s.id); return !!b && (b.body !== s.body || b.title !== s.title); };
// Built-in sections this notice doesn't have (removed, or new in the built-in text).
const missing = draft.builtIn.filter(b => !sections.some(s => s.id === b.id));
const pendingIds = sections.filter(s => updatedIds.has(s.id) && differs(s)).map(s => s.id);
/** Puts a built-in section back where it sits in the built-in text. */
const addBuiltIn = (b: NoticeSection) => {
const order = draft.builtIn.map(x => x.id);
const after = order.slice(0, order.indexOf(b.id)).reverse().find(id => sections.some(s => s.id === id));
const at = after ? sections.findIndex(s => s.id === after) + 1 : 0;
change([...sections.slice(0, at), { ...b }, ...sections.slice(at)]);
};
const useAllNew = () => {
if (!confirm("Replace every changed section with the new built-in text? Your own wording in those sections is replaced (other sections stay as they are). Nothing is public until you publish.")) return;
const next = sections.map(s => {
const b = updatedIds.has(s.id) ? builtInById.get(s.id) : undefined;
return b ? { ...b } : s;
});
change(next);
};
return (
<div className="space-y-5">
@@ -148,6 +185,24 @@ export function NoticeEditor({ token }: { token: string }) {
{dirty && <span className="self-center text-xs text-amber-700">Unsaved changes</span>}
</div>
{updates.length > 0 && (
<div className="border border-amber-200 bg-amber-50 rounded-xl p-4 text-sm text-amber-900 space-y-2" data-testid="builtin-updates">
<div className="flex items-center gap-2 font-medium"><Sparkles className="w-4 h-4" /> The built-in privacy notice has been updated</div>
<p>Your published notice keeps your own text, so the new wording from Cross Events {updates.map(u => u.revision).join(", ")} isn&apos;t in it yet:</p>
<ul className="list-disc pl-5">{updates.flatMap(u => u.summary).map((line, i) => <li key={i}>{line}</li>)}</ul>
<p>
{pendingIds.length > 0
? <>Sections with new text are marked below. Use the new text where you want it (it replaces your wording in that section), then save the draft and publish.</>
: <>Your draft already has the new text in every changed section. Save the draft and publish to make it live.</>}
{" "}Tick &quot;Significant change&quot; when publishing if people should accept it again.
</p>
<div className="flex flex-wrap gap-2">
{pendingIds.length > 0 && <button onClick={useAllNew} disabled={busy} className="px-3 py-1.5 rounded-lg bg-amber-600 text-white text-sm font-medium hover:bg-amber-700 disabled:opacity-50">Use all the new text</button>}
<button onClick={markReviewed} disabled={busy} className="px-3 py-1.5 rounded-lg border border-amber-300 bg-white text-sm hover:bg-amber-100 disabled:opacity-50">Done — hide this</button>
</div>
</div>
)}
{msg && <div className={`p-3 rounded-lg text-sm ${msg.type === "ok" ? "bg-green-50 text-green-800 border border-green-200" : "bg-red-50 text-red-800 border border-red-200"}`}>{msg.text}</div>}
{publishing && (
@@ -182,8 +237,9 @@ export function NoticeEditor({ token }: { token: string }) {
<div className="space-y-3">
{sections.map((s, i) => {
const original = builtInById.get(s.id);
const hasNew = updatedIds.has(s.id) && differs(s);
return (
<div key={`${s.id}-${i}`} className="border rounded-xl p-3 bg-white">
<div key={`${s.id}-${i}`} className={`border rounded-xl p-3 bg-white ${hasNew ? "border-amber-300" : ""}`} data-testid={hasNew ? "section-has-new-text" : undefined}>
<div className="flex items-center gap-2 mb-2">
<input className={`${inputCls} font-medium`} value={s.title} onChange={e => update(i, { title: e.target.value })} aria-label="Section title" />
<button onClick={() => move(i, -1)} disabled={i === 0} className="p-1.5 rounded hover:bg-gray-100 disabled:opacity-30" aria-label="Move up"><ArrowUp className="w-4 h-4" /></button>
@@ -194,9 +250,27 @@ export function NoticeEditor({ token }: { token: string }) {
<button onClick={() => confirm(`Remove "${s.title}"?`) && change(sections.filter((_, j) => j !== i))} className="p-1.5 rounded hover:bg-red-50 text-red-600" aria-label="Remove section"><Trash2 className="w-4 h-4" /></button>
</div>
<textarea className={`${inputCls} font-mono text-xs`} rows={Math.min(18, Math.max(3, s.body.split("\n").length + 1))} value={s.body} onChange={e => update(i, { body: e.target.value })} aria-label={`${s.title} text`} />
{hasNew && original && (
<details className="mt-2 text-xs">
<summary className="cursor-pointer text-amber-800 font-medium">New built-in text for this section — show it</summary>
<pre className="mt-2 whitespace-pre-wrap rounded-lg bg-amber-50 border border-amber-200 p-2 font-mono text-[11px] text-gray-700">{original.body}</pre>
<button onClick={() => update(i, { title: original.title, body: original.body })} className="mt-2 px-3 py-1.5 rounded-lg bg-amber-600 text-white hover:bg-amber-700">Use the new text</button>
</details>
)}
</div>
);
})}
{missing.length > 0 && (
<div className="border border-dashed rounded-xl p-3 text-sm text-gray-600 space-y-1">
<div className="font-medium text-gray-800">Built-in sections not in your notice</div>
{missing.map(b => (
<div key={b.id} className="flex items-center justify-between gap-2">
<span>{b.title}{updatedIds.has(b.id) && <span className="ml-1 text-xs text-amber-700">(new text)</span>}</span>
<button onClick={() => addBuiltIn(b)} className="inline-flex items-center gap-1 px-2 py-1 rounded border bg-white text-xs hover:bg-gray-50"><Plus className="w-3.5 h-3.5" /> Add</button>
</div>
))}
</div>
)}
<button onClick={() => change([...sections, { id: `section-${sections.length + 1}`, title: "New section", body: "" }])} className="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border bg-white text-sm hover:bg-gray-50">
<Plus className="w-4 h-4" /> Add section
</button>
@@ -9,11 +9,12 @@ import { errorMessage } from "@/lib/utils";
import type { PublicNotice } from "@/components/shared/PrivacyNoticeSection";
/**
* POPIA: a privacy notice version marked as a significant change has been published, and
* this person accepted an older one. Asked once after login; it can't be waved away, but the
* notice and the Privacy page (to delete the account instead) stay reachable.
* POPIA: asked once after login when this person never accepted the privacy notice (an account
* made for them, or from before acceptances were recorded) — reason "first" — or a version marked
* as a significant change came out after the one they accepted ("updated"). It can't be waved
* away, but the notice and the Privacy page (to delete the account instead) stay reachable.
*/
export function NoticePrompt({ onDone }: { onDone: () => void }) {
export function NoticePrompt({ reason = "updated", onDone }: { reason?: "first" | "updated"; onDone: () => void }) {
const { token } = useAuth();
const [notice, setNotice] = useState<PublicNotice | null>(null);
const [saving, setSaving] = useState(false);
@@ -40,7 +41,7 @@ export function NoticePrompt({ onDone }: { onDone: () => void }) {
};
// The newest version that needed accepting, for "what changed".
const changes = notice.versions.find(v => v.requiresAcceptance)?.changeSummary || notice.changeSummary;
const changes = reason === "updated" ? notice.versions.find(v => v.requiresAcceptance)?.changeSummary || notice.changeSummary : null;
return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4" role="dialog" aria-modal="true" aria-labelledby="notice-prompt-title">
@@ -49,7 +50,7 @@ export function NoticePrompt({ onDone }: { onDone: () => void }) {
<div className="w-9 h-9 rounded-lg flex items-center justify-center bg-brand-50 text-brand-600 shrink-0">
<ScrollText className="w-5 h-5" />
</div>
<h2 id="notice-prompt-title" className="text-lg font-semibold text-gray-900">We&apos;ve updated our privacy notice</h2>
<h2 id="notice-prompt-title" className="text-lg font-semibold text-gray-900">{reason === "first" ? "Our privacy notice" : <>We&apos;ve updated our privacy notice</>}</h2>
</div>
{changes && (
<div className="mb-3 p-3 rounded-lg bg-gray-50 border text-sm text-gray-700 whitespace-pre-line">
@@ -57,6 +58,7 @@ export function NoticePrompt({ onDone }: { onDone: () => void }) {
</div>
)}
<p className="text-sm text-gray-600 mb-5">
{reason === "first" && <>It explains what we keep about you and why, and your rights. </>}
Please read the <Link href="/legal/privacy" target="_blank" className="text-brand-600 hover:underline">privacy notice</Link> and
accept it to carry on using your account. If you don&apos;t agree, you can{" "}
<Link href="/dashboard/user/privacy" className="text-brand-600 hover:underline">delete your account</Link> instead.
@@ -42,7 +42,8 @@ export function PrivacyNoticeSection({ section, first = false }: { section: Noti
) : (
<h3 className="text-xl font-semibold text-brand-600 mb-3">{section.title}</h3>
)}
{section.id === "cookies" && (
{/* Above the cookie section: the built-in "cookies" one, or one an admin wrote about cookies. */}
{/cookie/i.test(section.id) && (
<CookieSettingsButton className="mb-3 px-3 py-1.5 text-sm rounded-lg border border-brand-300 text-brand-700 hover:bg-brand-50">
Change my cookie choice
</CookieSettingsButton>
@@ -18,6 +18,6 @@ export function PrivacyPrompts() {
const finishNotice = useCallback(() => setNoticeDone(true), []);
if (pathname === "/dashboard/user/privacy") return null;
if (user?.noticePromptPending && !noticeDone) return <NoticePrompt onDone={finishNotice} />;
if (user?.noticePromptPending && !noticeDone) return <NoticePrompt reason={user.noticePromptPending} onDone={finishNotice} />;
return <NewsPrompt />;
}
@@ -1,5 +1,5 @@
import React from "react";
import { Megaphone, Download, PencilLine, Trash2, MailX, Inbox, Clock, ShieldCheck, MessageCircle, ScrollText, Send, ListChecks, Building2, Eye, Gauge, Timer, AlertTriangle } from "lucide-react";
import { Megaphone, Download, PencilLine, Trash2, MailX, Inbox, Clock, ShieldCheck, MessageCircle, ScrollText, Send, ListChecks, Building2, Eye, Gauge, Timer, AlertTriangle, Sparkles, Users } from "lucide-react";
import { GuideItem } from "@/components/shared/GuideItem";
import type { HelpContent } from "./types";
@@ -79,6 +79,12 @@ export const adminPrivacyHelpContent: HelpContent = {
<GuideItem icon={ScrollText} title="Editing" tone="brand">
The notice starts from the built-in text. Change any section, add or remove sections, and save a draft — nothing is public until you publish. Placeholders like {"{org}"}, {"{ioName}"} and {"{operators}"} are filled in from Site settings and the operator register, so they stay up to date.
</GuideItem>
<GuideItem icon={Sparkles} title="When the built-in text is updated" tone="violet">
Until you publish your own version, the site shows the built-in text, so updates appear by themselves. Once you have published, your text stays as it is — after an update a yellow box lists what changed and marks the sections with new text. Show it, use it section by section (or all at once), save and publish. &quot;Done — hide this&quot; when you&apos;ve been through it.
</GuideItem>
<GuideItem icon={Users} title="How people agree to it" tone="blue">
At sign-up, and when they activate an account that was made for them (by staff, at the door or by whoever registered them). Anyone who has never agreed is asked once after they log in. Every agreement is in the consent log.
</GuideItem>
<GuideItem icon={Send} title="Publishing" tone="green">
Each publish is a numbered version with its date, and earlier versions stay readable on the privacy page. Tick &quot;Significant change&quot; and say what changed when people should accept it again — they&apos;re asked once, after they next log in. Leave it unticked for small fixes.
</GuideItem>
+2 -1
View File
@@ -12,7 +12,8 @@ export type AuthUser = {
// POPIA: hasn't answered the "news and announcements" opt-in question yet (asked once).
newsPromptPending?: boolean;
// POPIA: a privacy notice version they must accept has been published since they last did.
noticePromptPending?: boolean;
// Why the privacy notice must be accepted after login: never accepted, or a newer version needs it.
noticePromptPending?: false | "first" | "updated";
// Multi-campus: their home campus (the events page starts on it).
homeCampusId?: string | null;
// Campus-scoped staff: the campuses they're limited to (null = every campus).