feat(website): church details, settings, audit log, search engine data, safer editing

Church details saved through Accounts' church.update (live at once).
Settings: Search Console and Bing codes, Coming soon line, menu order.
Audit log and recent edits. A made share image, Event / VideoObject /
PodcastEpisode / BreadcrumbList structured data, permanent redirects
from old page addresses. Saves refused when someone else saved in
between; Ministry leaders' events; templates previewed with the
church's own content before choosing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 15:30:27 +02:00
co-authored by Claude Opus 5.5
parent d8ed238042
commit 085265392e
37 changed files with 951 additions and 91 deletions
@@ -0,0 +1,69 @@
"use client";
/**
* Settings (§10): the Coming soon line, search engine verification (live at once), and the menu's
* order (a draft, published with the site).
*/
import Link from "next/link";
import { useState } from "react";
import { api, canEdit } from "@/admin/api";
import { Btn, Field, inputClass, Loading, Notice, Panel, Title, useAction, useAdmin } from "@/admin/ui";
type Settings = { comingSoonText: string; googleVerification: string | null; bingVerification: string | null };
type PageRow = { id: string; kind: string; title: string; inNav: boolean };
export default function SettingsPage() {
const me = useAdmin<{ user: { role: string } }>("/me");
const settings = useAdmin<Settings>("/settings");
const pages = useAdmin<PageRow[]>("/pages");
const [form, setForm] = useState<Partial<Settings>>({});
const { busy, message, fields, run } = useAction();
if (!settings.data || !pages.data || !me.data) return <Loading error={settings.error ?? pages.error} />;
const editor = canEdit(me.data.user.role);
const s = { ...settings.data, ...form };
const menu = pages.data.filter((p) => p.kind !== "home");
const move = (i: number, d: -1 | 1) => run(async () => {
const list = [...menu];
[list[i], list[i + d]] = [list[i + d]!, list[i]!];
await api("/pages-order", { method: "PUT", body: { ids: list.map((p) => p.id) } });
await pages.reload();
}, "Saved as a draft: publish to change the menu.");
return (
<>
<Title sub="How your site is found, and its menu.">Settings</Title>
{message && <div className="mb-4"><Notice tone={message.tone}>{message.text}</Notice></div>}
<fieldset disabled={!editor} className="space-y-6">
<Panel title="Search engines">
<p className="mb-3 text-sm text-gray-600">To see how people find your site, add it to Google Search Console and Bing Webmaster Tools. They give you a code to prove the site is yours: paste it here (the whole tag is fine), save, then press Verify there. This goes live straight away.</p>
<div className="grid gap-4 sm:grid-cols-2">
<Field label="Google Search Console code" error={fields.googleVerification}><input className={inputClass} value={s.googleVerification ?? ""} onChange={(e) => setForm({ ...form, googleVerification: e.target.value })} /></Field>
<Field label="Bing Webmaster Tools code" error={fields.bingVerification}><input className={inputClass} value={s.bingVerification ?? ""} onChange={(e) => setForm({ ...form, bingVerification: e.target.value })} /></Field>
</div>
<p className="mt-3 text-sm text-gray-600">A Google Business Profile helps people find your church on Google Maps: set one up at business.google.com with the same address as your church details.</p>
</Panel>
<Panel title="Coming soon">
<Field label="The line under “Coming soon”" hint="Shown until you first publish your site." error={fields.comingSoonText}>
<input className={inputClass} value={s.comingSoonText} maxLength={300} onChange={(e) => setForm({ ...form, comingSoonText: e.target.value })} />
</Field>
</Panel>
{editor && Object.keys(form).length > 0 && (
<Btn kind="primary" busy={busy} onClick={() => run(async () => { settings.setData(await api<Settings>("/settings", { method: "PUT", body: form })); setForm({}); }, "Saved.")}>Save settings</Btn>
)}
<Panel title="Menu order">
<p className="mb-3 text-sm text-gray-600">Pages in the menu, in this order. Which pages show is set on each page (<Link href="/admin/pages" className="underline">Pages</Link>).</p>
<ul className="divide-y divide-gray-200">
{menu.map((p, i) => (
<li key={p.id} className="flex items-center justify-between gap-3 py-2">
<span>{p.title}{!p.inNav && <span className="text-sm text-gray-500"> (not in the menu)</span>}</span>
<span className="flex gap-1">
<Btn onClick={() => move(i, -1)} disabled={busy || i === 0} aria-label={`Move ${p.title} up`}>↑</Btn>
<Btn onClick={() => move(i, 1)} disabled={busy || i === menu.length - 1} aria-label={`Move ${p.title} down`}>↓</Btn>
</span>
</li>
))}
</ul>
</Panel>
</fieldset>
</>
);
}