"use client"; import { Suspense, useEffect, useMemo, useState } from "react"; import Link from "next/link"; import { useSearchParams } from "next/navigation"; import { Navbar } from "@/components/layout/Navbar"; import { Footer } from "@/components/layout/Footer"; import { useScrollSpy } from "@/hooks/useScrollSpy"; import { useSiteSettings } from "@/contexts/SiteSettingsContext"; import { ApiError } from "@/lib/api"; import { apiV2Data } from "@/lib/apiV2"; import { PrivacyNoticeSection, type PublicNotice } from "@/components/shared/PrivacyNoticeSection"; const fmtDate = (d: string) => new Date(d).toLocaleDateString(undefined, { day: "numeric", month: "long", year: "numeric" }); /** * The privacy notice. Its text comes from the backend: the published version edited in * Admin → Privacy (or the built-in notice before one is published), with the organisation's * details and operator register filled in. ?version=N shows an earlier version. */ function PrivacyNotice() { const versionParam = useSearchParams().get("version"); const { settings } = useSiteSettings(); const [notice, setNotice] = useState(null); const [error, setError] = useState(null); const sectionIds = useMemo(() => (notice?.sections || []).map(s => s.id), [notice]); const activeId = useScrollSpy(sectionIds); useEffect(() => { setNotice(null); setError(null); (apiV2Data("get", "/privacy/notice", { query: { version: versionParam || undefined } }) as Promise) .then(setNotice) .catch(e => setError(e instanceof ApiError ? e.message : "The privacy notice couldn't be loaded. Please try again.")); }, [versionParam]); const orgName = settings.org_name || "Cross Code"; const orgEmail = settings.org_email || "privacy@example.com"; const websiteUrl = settings.legal_website_url || "example.com"; const past = (notice?.versions || []).filter(v => v.version !== notice?.versions[0]?.version); return (

Privacy Policy

{error &&

{error}

} {!notice && !error &&

Loading…

} {notice && ( <>

Effective Date: {notice.effectiveDate} {!notice.builtIn && <> · Version {notice.version}}

{!notice.current && (
This is an earlier version of our privacy notice. Read the current version.
)}

Website:{" "} {websiteUrl}

Responsible Party: {orgName}

Email:{" "} {orgEmail}

{notice.sections.map((s, i) => )} {past.length > 0 && (

Earlier versions

    {notice.versions.map(v => (
  • Version {v.version} {" "} — {fmtDate(v.publishedAt)}{v.changeSummary ? `: ${v.changeSummary}` : ""}
  • ))}
)} )}
); } export default function PrivacyPolicyPage() { return (
}>
); }