Accounts 1.8.0, Website 1.1.0: admins redesigned as Cross Events' dashboard and settings

- Website: an icon sidebar in groups (Your site, Content, Go live, Team), a
  dashboard with cards and a tile per part of the admin, steps to the first
  publish across the top of every admin page, and a live preview beside the
  page editor and Template and style (computer or phone width, folds away,
  reloads on save). A framed request (Sec-Fetch-Dest: iframe) with an admin
  session reads the drafts, so no preview cookie is set. /preview/start
  takes ?to=. The page editor has Content and Page details tabs.
- Accounts: /admin is an overview (cards, "Needs you", a tile per section);
  People moved to /admin/people; the sidebar shows the part you're in,
  grouped, with a count on Deletion requests; People redesigned, with a
  confirm before Deactivate; Email and WhatsApp split into two cards.
- Both: darker grey labels for contrast; lucide-react in the Website.
- e2e: the live preview shows drafts while the site stays live; axe on the
  page editor.
- docs: VERSIONS, changelogs, WHATS-NEW.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-26 19:57:22 +02:00
co-authored by Claude Opus 5.5
parent e6c91c3705
commit dcc22a5c16
42 changed files with 1278 additions and 353 deletions
@@ -1,19 +1,27 @@
"use client";
/**
* One page (§6): its title, address, menu and search engine details, then its content. The home
* page has one of each homepage section (their layouts are set under Template and style); every
* other page is built from blocks, which can be added, moved and removed.
* One page (§6), with its live preview on the right. Content: the home page has one of each
* homepage section (their layouts, order and whether they show are under Template and style); every
* other page is built from blocks, which can be added, moved, hidden and removed. Page details: its
* title, address, menu and search engine details.
*/
import Link from "next/link";
import { useParams, useRouter } from "next/navigation";
import { useState } from "react";
import { useMemo, useState } from "react";
import {
ArrowDown, ArrowUp, CalendarDays, ChevronDown, ChevronRight, Clock, EyeOff, Eye, FileText, Heart, Image as ImageIcon, LayoutList, Megaphone, Mic,
Plus, Quote, Search, Settings2, Sparkles, Trash2, Type, Users, HandHeart, type LucideIcon,
} from "lucide-react";
import { api } from "@/admin/api";
import { BLOCK_FIELDS, DataForm, SECTION_FIELDS } from "@/admin/fields";
import { WithPreview } from "@/admin/LivePreview";
import { ImagePicker } from "@/admin/media";
import { Btn, Field, inputClass, Loading, Notice, Panel, Title, useAction, useAdmin } from "@/admin/ui";
import { Btn, cx, Field, inputClass, Loading, Notice, Panel, Tabs, Title, useAction, useAdmin } from "@/admin/ui";
type Section = { id: string; type: string; variant: string | null; hidden: boolean; data: Record<string, unknown>; updatedAt: string };
type PageData = { id: string; kind: string; slug: string; title: string; seoTitle: string | null; description: string | null; navLabel: string | null; inNav: boolean; imageId: string | null; updatedAt: string; sections: Section[] };
type Design = { home: { section: string; hidden: boolean }[] };
const HOME_ORDER = ["hero", "serviceTimes", "welcome", "ministries", "team", "events", "latestMessage", "invitation"];
const LISTS: Record<string, string> = {
@@ -23,25 +31,101 @@ const LISTS: Record<string, string> = {
messages: "This page lists your messages; blocks you add show after them.",
contact: "This page shows your church's contact details and service times from your church profile.",
};
const ICONS: Record<string, LucideIcon> = {
hero: Sparkles, serviceTimes: Clock, welcome: Heart, ministries: HandHeart, team: Users, events: CalendarDays, latestMessage: Mic, invitation: Megaphone,
text: Type, "image-text": ImageIcon, quote: Quote, cta: Megaphone,
};
const BLOCK_ABOUT: Record<string, string> = {
text: "A heading and paragraphs", "image-text": "A photo beside some text, with a button", quote: "Words someone said, and who said them", cta: "A short line and a button to act on",
};
function SectionEditor({ title, fields, initial, onSave, extra }: { title: string; fields: Parameters<typeof DataForm>[0]["fields"]; initial: Record<string, unknown>; onSave: (data: Record<string, unknown>) => Promise<unknown>; extra?: React.ReactNode }) {
/** A line about what a section says now, so it's recognisable folded. */
const summary = (data: Record<string, unknown>) => {
for (const k of ["headline", "heading", "quote", "text", "body"]) {
const v = data[k];
if (typeof v === "string" && v.trim()) return v.trim().split("\n")[0]!.slice(0, 90);
}
return null;
};
function SectionEditor({ type, title, fields, initial, onSave, hidden, extra }: {
type: string; title: string; fields: Parameters<typeof DataForm>[0]["fields"]; initial: Record<string, unknown>;
onSave: (data: Record<string, unknown>) => Promise<unknown>; hidden?: React.ReactNode; extra?: React.ReactNode;
}) {
const [value, setValue] = useState(initial);
const [open, setOpen] = useState(false);
const { busy, message, fields: errors, run } = useAction();
const Icon = ICONS[type] ?? FileText;
const line = summary(initial);
return (
<Panel>
<div className="flex items-center justify-between gap-3">
<h3 className="font-semibold">{title}</h3>
<div className="flex gap-2">{extra}<Btn onClick={() => setOpen(!open)} aria-expanded={open}>{open ? "Close" : "Edit"}</Btn></div>
<section className={cx("rounded-xl border bg-white shadow-sm", open ? "border-brand/40" : "border-gray-200")}>
<div className="flex items-center gap-2 p-3">
<button type="button" onClick={() => setOpen(!open)} aria-expanded={open} className="flex min-w-0 flex-1 items-center gap-3 rounded-lg p-1 text-left hover:bg-gray-50">
<span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-brand/10 text-brand-text" aria-hidden><Icon className="h-[18px] w-[18px]" /></span>
<span className="min-w-0 flex-1">
<span className="flex flex-wrap items-center gap-2 font-semibold text-gray-900">{title}{hidden}</span>
<span className="block truncate text-xs text-gray-500">{line ?? "Nothing written yet"}</span>
</span>
{open ? <ChevronDown className="h-4 w-4 shrink-0 text-gray-400" aria-hidden /> : <ChevronRight className="h-4 w-4 shrink-0 text-gray-400" aria-hidden />}
<span className="sr-only">{open ? "Close" : "Edit"}</span>
</button>
{extra && <div className="flex shrink-0 gap-1">{extra}</div>}
</div>
{open && (
<div className="mt-4 space-y-4">
<div className="space-y-4 border-t border-gray-100 p-4">
<DataForm fields={fields} value={value} onChange={setValue} errors={errors} />
<Btn kind="primary" busy={busy} onClick={() => run(() => onSave(value), "Saved as a draft.")}>Save</Btn>
{message && <Notice tone={message.tone}>{message.text}</Notice>}
<div className="flex flex-wrap items-center gap-3">
<Btn kind="primary" busy={busy} onClick={() => run(() => onSave(value), "Saved as a draft.")}>Save</Btn>
<Btn onClick={() => setOpen(false)}>Close</Btn>
{message && <Notice tone={message.tone}>{message.text}</Notice>}
</div>
</div>
)}
</Panel>
</section>
);
}
function Details({ page, setData }: { page: PageData; setData: (p: PageData) => void }) {
const { id } = useParams<{ id: string }>();
const details = useAction();
const [form, setForm] = useState<Partial<PageData> | null>(null);
const f = { ...page, ...form };
const saveDetails = () => details.run(async () => {
const p = await api<PageData>(`/pages/${id}`, { method: "PUT", body: { title: f.title, slug: f.slug, seoTitle: f.seoTitle, description: f.description, navLabel: f.navLabel, inNav: f.inNav, imageId: f.imageId, ifUpdatedAt: page.updatedAt } });
setData(p);
setForm(null);
}, "Saved as a draft.");
return (
<div className="space-y-6">
<Panel title="Title, address and menu" icon={Settings2}>
<div className="grid gap-4 sm:grid-cols-2">
<Field label="Title" error={details.fields.title}><input className={inputClass} value={f.title ?? ""} maxLength={120} onChange={(e) => setForm({ ...form, title: e.target.value })} /></Field>
{page.kind !== "home" && <Field label="Address" hint={`Your site/${f.slug}`} error={details.fields.slug}><input className={inputClass} value={f.slug ?? ""} onChange={(e) => setForm({ ...form, slug: e.target.value })} /></Field>}
{page.kind !== "home" && <Field label="Name in the menu" hint="Leave empty to use the title."><input className={inputClass} value={f.navLabel ?? ""} maxLength={40} onChange={(e) => setForm({ ...form, navLabel: e.target.value || null })} /></Field>}
{page.kind !== "home" && <label className="flex items-center gap-2 self-end pb-2 text-sm"><input type="checkbox" checked={!!f.inNav} onChange={(e) => setForm({ ...form, inNav: e.target.checked })} />Show in the menu</label>}
</div>
</Panel>
<Panel title="Search and sharing" icon={Search} sub="What search engines and shared links show for this page.">
<div className="grid gap-4 sm:grid-cols-2">
<Field label="Title in search results" hint={`${(f.seoTitle ?? f.title ?? "").length} of 60 characters`} error={details.fields.seoTitle}><input className={inputClass} value={f.seoTitle ?? ""} maxLength={70} onChange={(e) => setForm({ ...form, seoTitle: e.target.value || null })} placeholder={f.title} /></Field>
<Field label="Description in search results" hint={`${(f.description ?? "").length} of 155 characters${f.description ? "" : ": add one, so search engines show what this page is about"}`} error={details.fields.description}>
<textarea className={inputClass} rows={2} value={f.description ?? ""} maxLength={300} onChange={(e) => setForm({ ...form, description: e.target.value || null })} />
</Field>
<div className="sm:col-span-2"><ImagePicker label="Image when shared (optional)" value={f.imageId ?? null} onChange={(imageId) => setForm({ ...form, imageId })} /></div>
</div>
{/* A Google-style preview of the search result (ROADMAP-v3 §11). */}
<div className="mt-4 rounded-lg border border-gray-200 bg-gray-50 p-3" aria-label="How it may look in search results">
<p className="text-xs text-gray-500">In search results</p>
<p className="truncate text-lg text-blue-800">{f.seoTitle || f.title}</p>
<p className="line-clamp-2 text-sm text-gray-600">{f.description || "No description yet."}</p>
</div>
</Panel>
<div className="flex flex-wrap items-center gap-3">
<Btn kind="primary" busy={details.busy} onClick={saveDetails}>Save details</Btn>
{form && <Btn onClick={() => setForm(null)}>Undo</Btn>}
{details.message && <Notice tone={details.message.tone}>{details.message.text}</Notice>}
</div>
</div>
);
}
@@ -49,83 +133,86 @@ export default function EditPage() {
const { id } = useParams<{ id: string }>();
const router = useRouter();
const { data: page, error, setData } = useAdmin<PageData>(`/pages/${id}`);
const details = useAction();
const isHome = page?.kind === "home";
const design = useAdmin<{ design: Design }>(isHome ? "/design" : null);
const blocks = useAction();
const [form, setForm] = useState<Partial<PageData> | null>(null);
const remove = useAction();
const [tab, setTab] = useState<"content" | "details">("content");
// The saved page: when it changes (any save), the preview reloads.
const version = useMemo(() => (page ? JSON.stringify([page.updatedAt, page.slug, page.sections.map((s) => [s.id, s.updatedAt, s.hidden])]) : ""), [page]);
if (!page) return <Loading error={error} />;
const f = { ...page, ...form };
const saveDetails = () => details.run(async () => {
const p = await api<PageData>(`/pages/${id}`, { method: "PUT", body: { title: f.title, slug: f.slug, seoTitle: f.seoTitle, description: f.description, navLabel: f.navLabel, inNav: f.inNav, imageId: f.imageId, ifUpdatedAt: page.updatedAt } });
setData(p);
setForm(null);
}, "Saved as a draft.");
const blockCall = (path: string, method: string, body?: unknown) => blocks.run(async () => setData(await api<PageData>(`/pages/${id}${path}`, { method, body })));
const path = isHome ? "/" : `/${page.slug}`;
const blockCall = (p: string, method: string, body?: unknown) => blocks.run(async () => setData(await api<PageData>(`/pages/${id}${p}`, { method, body })));
// The home page's sections in the order the site shows them, and whether each shows.
const home = design.data?.design.home ?? HOME_ORDER.map((section) => ({ section, hidden: false }));
return (
<>
<Title sub={page.kind === "home" ? "Your home page" : `Your site/${page.slug}`}
actions={page.kind !== "home" && <Btn kind="danger" onClick={() => details.run(async () => { await api(`/pages/${id}`, { method: "DELETE" }); router.push("/admin/pages"); })}>Remove page</Btn>}>
<WithPreview path={path} version={version}>
<Link href="/admin/pages" className="mb-1 inline-block text-sm text-gray-500 hover:text-gray-800">← All pages</Link>
<Title icon={FileText} sub={isHome ? "Your home page" : `Your site/${page.slug}`}
actions={!isHome && <Btn kind="danger" busy={remove.busy} onClick={() => { if (window.confirm(`Remove “${page.title}”? It goes when you next publish.`)) void remove.run(async () => { await api(`/pages/${id}`, { method: "DELETE" }); router.push("/admin/pages"); }); }}><Trash2 className="h-4 w-4" aria-hidden />Remove page</Btn>}>
{page.title}
</Title>
<div className="space-y-6">
<Panel title="Page details">
<div className="grid gap-4 sm:grid-cols-2">
<Field label="Title" error={details.fields.title}><input className={inputClass} value={f.title ?? ""} maxLength={120} onChange={(e) => setForm({ ...form, title: e.target.value })} /></Field>
{page.kind !== "home" && <Field label="Address" hint={`Your site/${f.slug}`} error={details.fields.slug}><input className={inputClass} value={f.slug ?? ""} onChange={(e) => setForm({ ...form, slug: e.target.value })} /></Field>}
{page.kind !== "home" && <Field label="Name in the menu" hint="Leave empty to use the title."><input className={inputClass} value={f.navLabel ?? ""} maxLength={40} onChange={(e) => setForm({ ...form, navLabel: e.target.value || null })} /></Field>}
{page.kind !== "home" && <label className="flex items-center gap-2 self-end pb-2 text-sm"><input type="checkbox" checked={!!f.inNav} onChange={(e) => setForm({ ...form, inNav: e.target.checked })} />Show in the menu</label>}
<Field label="Title in search results" hint={`${(f.seoTitle ?? f.title ?? "").length} of 60 characters`} error={details.fields.seoTitle}><input className={inputClass} value={f.seoTitle ?? ""} maxLength={70} onChange={(e) => setForm({ ...form, seoTitle: e.target.value || null })} placeholder={f.title} /></Field>
<Field label="Description in search results" hint={`${(f.description ?? "").length} of 155 characters${f.description ? "" : ": add one, so search engines show what this page is about"}`} error={details.fields.description}>
<textarea className={inputClass} rows={2} value={f.description ?? ""} maxLength={300} onChange={(e) => setForm({ ...form, description: e.target.value || null })} />
</Field>
<div className="sm:col-span-2"><ImagePicker label="Image when shared (optional)" value={f.imageId ?? null} onChange={(imageId) => setForm({ ...form, imageId })} /></div>
</div>
{/* A Google-style preview of the search result (ROADMAP-v3 §11). */}
<div className="mt-4 rounded border border-gray-200 p-3" aria-label="How it may look in search results">
<p className="truncate text-lg text-blue-800">{f.seoTitle || f.title}</p>
<p className="line-clamp-2 text-sm text-gray-600">{f.description || "No description yet."}</p>
</div>
<div className="mt-4 flex items-center gap-3">
<Btn kind="primary" busy={details.busy} onClick={saveDetails}>Save details</Btn>
{details.message && <Notice tone={details.message.tone}>{details.message.text}</Notice>}
</div>
</Panel>
{remove.message?.tone === "error" && <div className="mb-4"><Notice tone="error">{remove.message.text}</Notice></div>}
{page.kind === "home" ? (
<>
<p className="text-sm text-gray-600">Each section&apos;s layout, order and whether it shows are under Template and style.</p>
{HOME_ORDER.map((type) => {
const s = page.sections.find((x) => x.type === type);
const spec = SECTION_FIELDS[type]!;
return <SectionEditor key={type} title={spec.name} fields={spec.fields} initial={s?.data ?? {}} onSave={async (data) => setData(await api<PageData>(`/pages/${id}/home/${type}`, { method: "PUT", body: { data, ifUpdatedAt: s?.updatedAt } }))} />;
})}
</>
) : (
<>
{LISTS[page.kind] && <Notice>{LISTS[page.kind]}</Notice>}
{page.sections.map((s, i) => {
const spec = BLOCK_FIELDS[s.type];
if (!spec) return null;
return (
<SectionEditor key={s.id} title={`${spec.name}${s.hidden ? " (hidden)" : ""}`} fields={spec.fields} initial={s.data}
onSave={async (data) => setData(await api<PageData>(`/pages/${id}/blocks/${s.id}`, { method: "PUT", body: { data, ifUpdatedAt: s.updatedAt } }))}
extra={<>
<Btn onClick={() => blockCall(`/blocks/${s.id}/move`, "POST", { direction: "up" })} disabled={i === 0} aria-label="Move up">↑</Btn>
<Btn onClick={() => blockCall(`/blocks/${s.id}/move`, "POST", { direction: "down" })} disabled={i === page.sections.length - 1} aria-label="Move down">↓</Btn>
<Btn onClick={() => blockCall(`/blocks/${s.id}`, "PUT", { hidden: !s.hidden })}>{s.hidden ? "Show" : "Hide"}</Btn>
<Btn kind="danger" onClick={() => blockCall(`/blocks/${s.id}`, "DELETE")}>Remove</Btn>
</>} />
);
})}
<Panel title="Add a block">
<div className="flex flex-wrap gap-2">
{Object.entries(BLOCK_FIELDS).map(([type, spec]) => <Btn key={type} busy={blocks.busy} onClick={() => blockCall("/blocks", "POST", { type })}>{spec.name}</Btn>)}
</div>
{blocks.message && <div className="mt-3"><Notice tone={blocks.message.tone}>{blocks.message.text}</Notice></div>}
</Panel>
</>
)}
<Tabs label="This page" value={tab} onChange={setTab} tabs={[
{ id: "content", label: isHome ? "Sections" : "Content", icon: LayoutList },
{ id: "details", label: "Page details", icon: Settings2 },
]} />
{/* Both stay mounted, so switching tabs keeps what's not saved yet. */}
<div hidden={tab !== "details"}><Details page={page} setData={setData} /></div>
<div hidden={tab !== "content"}>
{isHome ? (
<div className="space-y-3">
<Notice>Open a section to change what it says. Its layout, its place on the page and whether it shows are under <Link href="/admin/template" className="font-semibold underline">Template and style</Link>.</Notice>
{home.map(({ section: type, hidden }) => {
const s = page.sections.find((x) => x.type === type);
const spec = SECTION_FIELDS[type];
if (!spec) return null;
return <SectionEditor key={type} type={type} title={spec.name} fields={spec.fields} initial={s?.data ?? {}}
hidden={hidden && <span className="inline-flex items-center gap-1 rounded-full bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-600"><EyeOff className="h-3 w-3" aria-hidden />Not shown</span>}
onSave={async (data) => setData(await api<PageData>(`/pages/${id}/home/${type}`, { method: "PUT", body: { data, ifUpdatedAt: s?.updatedAt } }))} />;
})}
</div>
) : (
<div className="space-y-3">
{LISTS[page.kind] && <Notice>{LISTS[page.kind]}</Notice>}
{page.sections.length === 0 && <p className="rounded-xl border border-dashed border-gray-300 p-6 text-center text-sm text-gray-500">Nothing on this page yet: add a block below.</p>}
{page.sections.map((s, i) => {
const spec = BLOCK_FIELDS[s.type];
if (!spec) return null;
return (
<SectionEditor key={s.id} type={s.type} title={spec.name} fields={spec.fields} initial={s.data}
hidden={s.hidden && <span className="inline-flex items-center gap-1 rounded-full bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-600"><EyeOff className="h-3 w-3" aria-hidden />Hidden</span>}
onSave={async (data) => setData(await api<PageData>(`/pages/${id}/blocks/${s.id}`, { method: "PUT", body: { data, ifUpdatedAt: s.updatedAt } }))}
extra={<>
<Btn kind="icon" onClick={() => blockCall(`/blocks/${s.id}/move`, "POST", { direction: "up" })} disabled={i === 0} aria-label="Move up" title="Move up"><ArrowUp className="h-4 w-4" aria-hidden /></Btn>
<Btn kind="icon" onClick={() => blockCall(`/blocks/${s.id}/move`, "POST", { direction: "down" })} disabled={i === page.sections.length - 1} aria-label="Move down" title="Move down"><ArrowDown className="h-4 w-4" aria-hidden /></Btn>
<Btn kind="icon" onClick={() => blockCall(`/blocks/${s.id}`, "PUT", { hidden: !s.hidden })} aria-label={s.hidden ? "Show" : "Hide"} title={s.hidden ? "Show it" : "Hide it"}>{s.hidden ? <Eye className="h-4 w-4" aria-hidden /> : <EyeOff className="h-4 w-4" aria-hidden />}</Btn>
<Btn kind="icon" className="hover:!text-red-700" onClick={() => { if (window.confirm(`Remove this ${spec.name.toLowerCase()} block?`)) void blockCall(`/blocks/${s.id}`, "DELETE"); }} aria-label="Remove" title="Remove"><Trash2 className="h-4 w-4" aria-hidden /></Btn>
</>} />
);
})}
<Panel title="Add a block" icon={Plus} className="!mt-6">
<div className="grid gap-2 sm:grid-cols-2">
{Object.entries(BLOCK_FIELDS).map(([type, spec]) => {
const Icon = ICONS[type] ?? FileText;
return (
<button key={type} type="button" disabled={blocks.busy} onClick={() => blockCall("/blocks", "POST", { type })}
className="flex items-start gap-3 rounded-lg border border-gray-200 p-3 text-left hover:border-brand/40 hover:bg-brand/5 disabled:opacity-50">
<Icon className="mt-0.5 h-5 w-5 shrink-0 text-brand-text" aria-hidden />
<span><span className="block text-sm font-semibold text-gray-900">{spec.name}</span><span className="block text-xs text-gray-500">{BLOCK_ABOUT[type] ?? ""}</span></span>
</button>
);
})}
</div>
{blocks.message && <div className="mt-3"><Notice tone={blocks.message.tone}>{blocks.message.text}</Notice></div>}
</Panel>
</div>
)}
</div>
</>
</WithPreview>
);
}
@@ -3,12 +3,19 @@
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useState } from "react";
import {
BookOpen, Building2, CalendarDays, ChevronRight, FileText, Gift, HandHeart, Home, Mail, MapPin, Mic, Plus, ShieldCheck, Users, type LucideIcon,
} from "lucide-react";
import { api } from "@/admin/api";
import { Btn, Field, inputClass, Loading, Notice, Panel, Title, useAction, useAdmin } from "@/admin/ui";
type PageRow = { id: string; kind: string; slug: string; title: string; inNav: boolean; path: string };
const KINDS: Record<string, string> = { home: "Home", visit: "Plan your visit", about: "About", leadership: "Leadership", ministries: "Ministries", events: "Events", messages: "Messages", give: "Give", contact: "Contact", terms: "Terms", safeguarding: "Safeguarding", custom: "Your own page" };
const KINDS: Record<string, [string, LucideIcon]> = {
home: ["Home", Home], visit: ["Plan your visit", MapPin], about: ["About", Building2], leadership: ["Leadership", Users], ministries: ["Ministries", HandHeart],
events: ["Events", CalendarDays], messages: ["Messages", Mic], give: ["Give", Gift], contact: ["Contact", Mail], terms: ["Terms", BookOpen],
safeguarding: ["Safeguarding", ShieldCheck], custom: ["Your own page", FileText],
};
/** Pages (§6): the fixed ones and the church's own, built from blocks. */
export default function Pages() {
@@ -24,22 +31,29 @@ export default function Pages() {
});
return (
<>
<Title sub="Each page is a draft until you publish.">Pages</Title>
<Title icon={FileText} sub="Open a page to change what it says, with a live preview beside it. Each change is a draft until you publish.">Pages</Title>
<div className="grid gap-6 lg:grid-cols-[2fr_1fr]">
<Panel>
<ul className="divide-y divide-gray-200">
{data.map((p) => (
<li key={p.id} className="flex items-center justify-between gap-3 py-3">
<div>
<Link href={`/admin/pages/${p.id}`} className="font-medium underline-offset-4 hover:underline">{p.title}</Link>
<p className="text-xs text-gray-500">{KINDS[p.kind] ?? p.kind} · {p.path}{!p.inNav && p.kind !== "home" && " · not in the menu"}</p>
</div>
<Link href={`/admin/pages/${p.id}`} className="text-sm font-semibold text-brand-text">Edit</Link>
</li>
))}
<Panel className="!p-2">
<ul className="divide-y divide-gray-100">
{data.map((p) => {
const [kind, Icon] = KINDS[p.kind] ?? [p.kind, FileText];
return (
<li key={p.id}>
<Link href={`/admin/pages/${p.id}`} className="group flex items-center gap-3 rounded-lg px-3 py-3 hover:bg-gray-50">
<span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-brand/10 text-brand-text" aria-hidden><Icon className="h-[18px] w-[18px]" /></span>
<span className="min-w-0 flex-1">
<span className="block font-medium text-gray-900">{p.title}</span>
<span className="block truncate text-xs text-gray-500">{kind} · {p.path}</span>
</span>
{p.kind !== "home" && !p.inNav && <span className="hidden rounded-full bg-gray-100 px-2 py-0.5 text-xs text-gray-600 sm:inline">Not in the menu</span>}
<ChevronRight className="h-4 w-4 shrink-0 text-gray-300 group-hover:text-gray-500" aria-hidden />
</Link>
</li>
);
})}
</ul>
</Panel>
<Panel title="Add a page">
<Panel title="Add a page" icon={Plus} sub="Your own page, built from blocks." className="self-start">
<div className="space-y-3">
<Field label="Title" error={fields.title}><input className={inputClass} value={title} maxLength={120} onChange={(e) => { setTitle(e.target.value); setSlug(e.target.value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "")); }} /></Field>
<Field label="Address" hint={`Your site/${slug || "…"}`} error={fields.slug}><input className={inputClass} value={slug} maxLength={80} onChange={(e) => setSlug(e.target.value)} /></Field>