Privacy policy link in the footer and checkout, notes hint, and a policy draft

Site design → Footer picks the privacy policy page; it is linked from the footer and from a short notice above Pay. The notes field asks customers not to write health details (special-category data). 'Create a privacy policy draft' makes an unpublished page describing what this software does with customer data, with gaps for the studio to fill in. No consent checkbox: booking data is processed to perform the contract. Also adds the PrivacyGlobal type used by the retention settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VaXE9U7AmW3dfD2w6cbLfk
This commit is contained in:
agent 2026-10-24 10:44:45 +00:00
parent 73e8c5dc5d
commit 5828d65a00
7 changed files with 129 additions and 5 deletions

View file

@ -1,5 +1,6 @@
import { fail } from '@sveltejs/kit';
import { fail, redirect } from '@sveltejs/kit';
import { ClientResponseError } from 'pocketbase';
import { PRIVACY_PAGE_SLUG, privacyTemplateHtml } from '$lib/admin/privacyTemplate';
import { attempt } from '$lib/server/actions';
import { defaultColors, defaultFooter, defaultHeader } from '$lib/types';
import type { Actions, PageServerLoad } from './$types';
@ -51,5 +52,19 @@ export const actions: Actions = {
const result = await attempt('Could not save.', () => locals.pb.collection('globals').update(id, { data: value }));
if (!result.ok) return fail(400, { section, ok: false, message: result.failure.data.message });
return { section, ok: true, message: 'Saved.' };
},
// An unpublished privacy policy page to fill in, opened in the page editor.
createPrivacyDraft: async ({ locals }) => {
const result = await attempt('Could not create the privacy policy draft.', () =>
locals.pb.collection('pages').create({
slug: PRIVACY_PAGE_SLUG,
title: 'Privacy policy',
published: false,
blocks: [{ id: crypto.randomUUID(), type: 'text', data: { content: privacyTemplateHtml } }]
})
);
if (!result.ok) return fail(400, { section: 'footer', ok: false, message: result.failure.data.message });
redirect(303, `/pages/${PRIVACY_PAGE_SLUG}`);
}
};

View file

@ -1,6 +1,7 @@
<script lang="ts">
import { enhance } from '$app/forms';
import ImageUploader from '$lib/admin/editors/ImageUploader.svelte';
import { PRIVACY_PAGE_SLUG } from '$lib/admin/privacyTemplate';
import type { SubmitFunction } from '@sveltejs/kit';
let { data, form } = $props();
@ -10,6 +11,7 @@
let saving = $state('');
// Older records may predate the CTA button; the inputs below need an object.
header.ctaButton ??= { label: '', href: '' };
footer.privacyPage ??= '';
function addHeaderLink() { header.navLinks = [...(header.navLinks || []), { label: '', href: '' }]; }
function addSocial() { footer.socialLinks = [...(footer.socialLinks || []), { platform: '', url: '' }]; }
@ -124,6 +126,18 @@
</div>
{/each}
<button class="btn btn-sm mt-1" type="button" onclick={addSocial}>Add social link</button>
<h3 class="mt-6 mb-2 font-bold">Privacy policy page</h3>
<select class="select w-full" aria-label="Privacy policy page" bind:value={footer.privacyPage}>
<option value="">— None —</option>
{#each data.pages as page (page.id)}
<option value={page.slug}>{page.title} [{page.slug}]</option>
{/each}
</select>
<p class="mt-1 text-sm text-base-content/60">Linked from the footer and the checkout. Only published pages work as links.</p>
{#if !data.pages.some((page) => page.slug === PRIVACY_PAGE_SLUG)}
<button class="btn btn-sm mt-2 self-start" type="submit" formaction="?/createPrivacyDraft" formnovalidate>Create a privacy policy draft</button>
<p class="mt-1 text-sm text-base-content/60">An unpublished page describing what this site does with customer data, with [gaps] for you to fill in. You're responsible for it being accurate.</p>
{/if}
{@render saveButton('footer', 'Save footer')}
</form>