"use client"; import Link from "next/link"; import React, { useState } from "react"; import { Activity, Building2, DatabaseBackup, FileText, KeyRound, LayoutDashboard, Link2, Lock, LogIn, LogOut, Mail, Menu, ScrollText, ShieldCheck, Timer, User, Users, UserX, X, type LucideIcon, } from "lucide-react"; import { ChurchMark } from "@crosscode/ui"; import { useBranding } from "@/components/BrandingProvider"; /** Who's signed in, as the shell shows them (null: a public page such as the privacy notice). */ export type ShellUser = { name: string; email: string; role: "member" | "admin" }; type NavItem = { href: string; label: string; icon: LucideIcon }; export const ACCOUNT_NAV: NavItem[] = [ { href: "/account", label: "Overview", icon: LayoutDashboard }, { href: "/account/details", label: "Your details", icon: User }, { href: "/account/security", label: "Signing in", icon: ShieldCheck }, { href: "/account/privacy", label: "Privacy", icon: Lock }, { href: "/account/activity", label: "Activity", icon: Activity }, ]; export const ADMIN_NAV: NavItem[] = [ { href: "/admin", label: "People", icon: Users }, { href: "/admin/deletions", label: "Deletion requests", icon: UserX }, { href: "/admin/church", label: "Church profile", icon: Building2 }, { href: "/admin/linked", label: "Linked products", icon: Link2 }, { href: "/admin/signin", label: "Sign-in settings", icon: LogIn }, { href: "/admin/messages", label: "Email and WhatsApp", icon: Mail }, { href: "/admin/notice", label: "Privacy notice", icon: FileText }, { href: "/admin/backups", label: "Backups", icon: DatabaseBackup }, { href: "/admin/jobs", label: "Background jobs", icon: Timer }, { href: "/admin/licence", label: "Licence", icon: KeyRound }, { href: "/admin/audit", label: "Audit log", icon: ScrollText }, ]; /** Signs out of Accounts and every site of the church (RP-initiated logout), ending on /signed-out. */ export function signOutHref() { return `/api/oidc/session/end?client_id=accounts-self&post_logout_redirect_uri=${encodeURIComponent(`${window.location.origin}/signed-out`)}`; } const initials = (name: string) => name.split(/\s+/).filter(Boolean).slice(0, 2).map((p) => p[0]!.toUpperCase()).join("") || "?"; function Avatar({ name, small }: { name: string; small?: boolean }) { return {initials(name)}; } function RoleBadge({ role }: { role: ShellUser["role"] }) { return role === "admin" ? Accounts admin : Member; } function NavList({ title, items, active, onNavigate }: { title: string; items: NavItem[]; active: string; onNavigate?: () => void }) { return (
{title}
{sub}
}Loading…