Files
crosscode-platform/apps/events/frontend/src/components/shared/PrivacyNoticeSection.tsx
T
joshuaandClaude Opus 5.5 adb6e11000 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>
2026-10-28 13:15:57 +02:00

61 lines
2.3 KiB
TypeScript

"use client";
import React from "react";
import { CookieSettingsButton } from "@/components/shared/CookieSettingsButton";
export type NoticeSection = { id: string; title: string; body: string };
export type PublicNotice = {
version: number;
builtIn: boolean;
current: boolean;
publishedAt: string | null;
effectiveDate: string;
changeSummary: string | null;
sections: NoticeSection[];
versions: { version: number; publishedAt: string; changeSummary: string | null; requiresAcceptance: boolean }[];
};
// Email addresses, web addresses and bare "www." names in notice text become links.
const LINK_RE = /([\w.+-]+@[\w-]+\.[\w.]+|https?:\/\/[^\s)]+|www\.[\w-]+\.[\w.]+)/g;
function linkify(line: string) {
const parts = line.split(LINK_RE);
return parts.map((part, i) => {
if (i % 2 === 0) return part;
const href = part.includes("@") && !part.startsWith("http") ? `mailto:${part}` : part.startsWith("http") ? part : `https://${part}`;
return (
<a key={i} href={href} className="text-brand-600 hover:underline break-all" {...(href.startsWith("http") ? { target: "_blank", rel: "noopener noreferrer" } : {})}>
{part}
</a>
);
});
}
/** One section of the privacy notice: one paragraph per line, "• " lines as bullets. */
export function PrivacyNoticeSection({ section, first = false }: { section: NoticeSection; first?: boolean }) {
const lines = section.body.split("\n").filter(l => l.trim() !== "");
return (
<section id={section.id} className="mb-10 scroll-mt-24">
{first ? (
<h2 className="text-2xl font-semibold text-brand-600 mb-4">{section.title}</h2>
) : (
<h3 className="text-xl font-semibold text-brand-600 mb-3">{section.title}</h3>
)}
{/* 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>
)}
{lines.map((line, i) =>
line.startsWith("• ") ? (
<p key={i} className="mb-1.5 pl-5 -indent-3">{"• "}{linkify(line.slice(2))}</p>
) : (
<p key={i} className="mb-2">{linkify(line)}</p>
),
)}
</section>
);
}