Add parental consent for youth events

Youth events need a name and date of birth for every attendee, and a
parent/guardian's details for under-18s. Parents get an email and
WhatsApp link to a consent page that records the signed name, time, IP,
device and exact consent text; medical and emergency details are stored
encrypted. Tickets are issued but check-in is blocked until consent is
given (supervisor override audited). A daily job sends reminders and
purges medical details after the retention period. Adds a supervisor
consent tracker, consent status and medical list reports, and clears
consent data when an account is anonymised.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-19 13:24:44 +02:00
co-authored by Claude Opus 5.5
parent 03b79972e6
commit f55353ecc6
41 changed files with 1988 additions and 88 deletions
@@ -36,6 +36,9 @@ export default function TicketScanningPage() {
remaining: number;
} | null>(null);
const [confirmQty, setConfirmQty] = useState(1);
// Youth events: the preview says whether parental consent allows check-in.
const consentBlocked = !!confirmModal && !['not_required', 'given', undefined].includes(confirmModal.ticket?.consentStatus);
const canOverrideConsent = user?.role === 'admin' || user?.role === 'supervisor';
const [confirmQtyRaw, setConfirmQtyRaw] = useState("1");
// Event selection state
@@ -165,7 +168,7 @@ export default function TicketScanningPage() {
}
}
async function commitScan() {
async function commitScan(overrideConsent = false) {
if (!confirmModal || !token) return;
// Capture everything before clearing modal state
@@ -199,7 +202,7 @@ export default function TicketScanningPage() {
await apiFetch<any>(url, {
method: "POST",
authToken: token,
body: { qty },
body: { qty, ...(overrideConsent ? { overrideConsent: true } : {}) },
});
refreshStatsAndRecent();
} catch (e: any) {
@@ -383,6 +386,17 @@ export default function TicketScanningPage() {
<div><span className="font-medium">Remaining:</span> <span className={confirmModal.remaining < (confirmModal.ticket?.quantity || 1) ? 'text-amber-600 font-semibold' : 'text-green-700 font-semibold'}>{confirmModal.remaining}</span></div>
</div>
{consentBlocked && (
<div className="mb-4 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-800">
<div className="font-semibold">
{confirmModal.ticket?.consentStatus === 'declined' ? 'Parental consent was declined'
: confirmModal.ticket?.consentStatus === 'pending' ? 'Parental consent is still pending'
: 'Parental consent is missing'}
</div>
<div className="mt-1">This person can&apos;t be checked in until a parent or guardian gives consent.{canOverrideConsent ? ' As a supervisor you can override this — it is recorded in the audit log.' : ' Ask a supervisor.'}</div>
</div>
)}
{(confirmModal.ticket?.quantity || 1) > 1 && (
<div className="mb-4">
<label className="block text-sm font-medium text-gray-700 mb-1">Qty to redeem (max {confirmModal.remaining})</label>
@@ -411,12 +425,23 @@ export default function TicketScanningPage() {
>
Cancel
</button>
<button
onClick={commitScan}
className="flex-1 px-4 py-2 rounded-lg bg-brand-600 text-white text-sm font-semibold hover:bg-brand-700"
>
Confirm Scan
</button>
{consentBlocked ? (
canOverrideConsent && (
<button
onClick={() => commitScan(true)}
className="flex-1 px-4 py-2 rounded-lg bg-red-600 text-white text-sm font-semibold hover:bg-red-700"
>
Override and check in
</button>
)
) : (
<button
onClick={() => commitScan()}
className="flex-1 px-4 py-2 rounded-lg bg-brand-600 text-white text-sm font-semibold hover:bg-brand-700"
>
Confirm Scan
</button>
)}
</div>
</div>
</div>