// Legal pages — Privacy, Terms, Cookie Policy, GDPR.
//
// There is no copy in this file on purpose. The documents live in legal-content.php, which
// renders them server-side AND emits them as window.AM_LEGAL for this component. Writing the
// text twice would let the two versions drift, and a legal page that disagrees with itself
// depending on whether JavaScript ran is worse than no page at all.
//
// Keep the block types here in step with AM_legalHTML() in legal-content.php.
function LegalBlock({ block }) {
if (block.type === "p") return
{block.text}
;
if (block.type === "note") return
{block.text}
;
if (block.type === "ul") {
return
{block.items.map((it, i) =>
{it}
)}
;
}
if (block.type === "table") {
return (
// Wrapped so a wide table scrolls inside itself rather than making the page scroll
// sideways on a phone.
{block.head.map((h, i) =>
{h}
)}
{block.rows.map((r, i) => (
{r.map((c, j) =>
{c}
)}
))}
);
}
return null;
}
// `route` picks the document: index.php emits all four keyed by route name, because the
// footer links between them are SPA navigations that never reload the page.
function LegalPage({ route }) {
const all = typeof window !== "undefined" ? window.AM_LEGAL : null;
const doc = all && route ? all[route] : null;
// Only reachable if someone lands on a legal route without the payload — a stale cached
// index.php, say. Say so rather than rendering an empty page that looks like the policy.
if (!doc || !doc.sections) {
return (
Document unavailable
We couldn't load this document. Please reload the page, or email
{" "}info@activemanage.co.uk and we'll send it to you.
);
}
const jump = (e, id) => {
e.preventDefault();
const el = document.getElementById(id);
if (!el) return;
window.scrollTo({ top: el.getBoundingClientRect().top + window.scrollY - 80, behavior: "smooth" });
// Put the section in the URL so it can be linked to and Back still works.
window.history.replaceState({}, "", window.location.pathname + "#" + id);
};
return (