"use client"; 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 = { 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() { const { data, error } = useAdmin("/pages"); const router = useRouter(); const [title, setTitle] = useState(""); const [slug, setSlug] = useState(""); const { busy, message, fields, run } = useAction(); if (!data) return ; const create = () => run(async () => { const p = await api<{ id: string }>("/pages", { body: { title, slug } }); router.push(`/admin/pages/${p.id}`); }); return ( <> Pages
    {data.map((p) => { const [kind, Icon] = KINDS[p.kind] ?? [p.kind, FileText]; return (
  • {p.title} {kind} · {p.path} {p.kind !== "home" && !p.inNav && Not in the menu}
  • ); })}
{ setTitle(e.target.value); setSlug(e.target.value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "")); }} /> setSlug(e.target.value)} /> Add page {message && {message.text}}
); }