Files
crosscode-platform/apps/website/frontend/src/admin/Shell.tsx
T
joshuaandClaude Opus 5.5 b767b45e64 feat(website): the event feed both ways, and Linked products
Publish my events: the Website's simple events as crosscode.event/1
(GET /api/feed/v1/events, updatedSince, removals in deleted for 90
days) and a signed event.changed to linked siblings. Show events
from: each sibling's feed every 15 minutes and at once on its signed
event.changed; read-only copies of only that sibling's events, one
bad event skipped, the last good copy kept. Admin: Linked products.
church.changed from Accounts refreshes the profile at once. Plan:
the video hero, more blocks and more pages move to website@1.1.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:37:42 +02:00

59 lines
3.1 KiB
TypeScript

"use client";
/** The admin's frame: navigation, the pending change count, Preview and Sign out (§4, §10). */
import Link from "next/link";
import { usePathname } from "next/navigation";
import { ROLE_NAMES } from "./api";
import { cx, useAdmin } from "./ui";
const NAV = [
{ href: "/admin", label: "Dashboard" },
{ href: "/admin/template", label: "Template and style" },
{ href: "/admin/pages", label: "Pages" },
{ href: "/admin/ministries", label: "Ministries" },
{ href: "/admin/leaders", label: "Leadership" },
{ href: "/admin/messages", label: "Messages" },
{ href: "/admin/events", label: "Events" },
{ href: "/admin/linked", label: "Linked products" },
{ href: "/admin/media", label: "Media library" },
{ href: "/admin/publish", label: "Publish and history" },
{ href: "/admin/people", label: "People", managers: true },
];
export function AdminShell({ user, children }: { user: { name: string; role: string }; children: React.ReactNode }) {
const path = usePathname();
const { data } = useAdmin<{ pending: number }>(`/overview?for=${encodeURIComponent(path)}`);
return (
<div className="min-h-screen bg-gray-50 font-sans text-gray-900">
<header className="border-b border-gray-200 bg-white">
<div className="mx-auto flex max-w-6xl flex-wrap items-center justify-between gap-3 px-4 py-3">
<Link href="/admin" className="font-semibold">Website admin</Link>
<div className="flex flex-wrap items-center gap-3 text-sm">
{data && data.pending > 0 && <Link href="/admin/publish" className="rounded-full bg-amber-100 px-3 py-1 font-medium text-amber-900">{data.pending} {data.pending === 1 ? "change" : "changes"} not published</Link>}
{/* eslint-disable-next-line @next/next/no-html-link-for-pages -- a route handler that sets the preview cookie: a full page load, not a client navigation */}
<a href="/preview/start" className="rounded-md border border-gray-300 px-3 py-1.5 font-semibold hover:bg-gray-50">Preview</a>
<span className="text-gray-600">{user.name} · {ROLE_NAMES[user.role] ?? user.role}</span>
<form method="post" action="/api/auth/signout"><button type="submit" className="text-gray-600 underline-offset-4 hover:underline">Sign out</button></form>
</div>
</div>
</header>
<div className="mx-auto grid max-w-6xl gap-6 px-4 py-6 md:grid-cols-[13rem_1fr]">
<nav aria-label="Admin">
<ul className="flex gap-1 overflow-x-auto md:flex-col">
{NAV.filter((n) => !("managers" in n) || ["owner", "admin"].includes(user.role)).map((n) => {
const current = n.href === "/admin" ? path === "/admin" : path.startsWith(n.href);
return (
<li key={n.href}>
<Link href={n.href} aria-current={current ? "page" : undefined}
className={cx("block whitespace-nowrap rounded-md px-3 py-2 text-sm", current ? "bg-brand text-brand-on" : "text-gray-700 hover:bg-gray-100")}>{n.label}</Link>
</li>
);
})}
</ul>
</nav>
<main>{children}</main>
</div>
</div>
);
}