import { NavLink, Outlet, useLocation } from "react-router-dom"; import { useAuth } from "@/features/auth/AuthProvider"; import { Icon, type IconName } from "@/components/Icon"; import { Ltr } from "@/components/ui"; import { t } from "@/strings/ar"; /** * The administration space, per ContiAI Admin.dc.html. * * Same rail as the product - dark navy, 258px, the mark as a watermark - so * the two spaces are recognisably one system. What distinguishes them is the * navigation itself, which is the honest signal: seven administrative * destinations rather than four working ones. * * There is deliberately no banner across the top. The rail already says where * you are on every screen, and a fixed bar repeating it cost 46px of vertical * space on every page to tell an administrator something they knew. */ const NAV: { to: string; label: string; icon: IconName; end?: boolean }[] = [ { to: "/admin", label: t.admin.overview, icon: "grid", end: true }, { to: "/admin/users", label: t.admin.users, icon: "user" }, { to: "/admin/usage", label: "الاستهلاك التفصيلي", icon: "bars" }, { to: "/admin/runs", label: t.admin.runs, icon: "playRing" }, { to: "/admin/task-types", label: t.admin.taskTypes, icon: "book" }, { to: "/admin/announcements", label: t.admin.announcements, icon: "bell" }, { to: "/admin/audit", label: t.admin.audit, icon: "shield" }, ]; function Item({ item }: { item: (typeof NAV)[number] }) { return ( [ "flex min-h-11 items-center gap-3 rounded-md px-3 py-2.5", "text-item transition-colors duration-200", isActive ? "bg-[var(--color-brand-700)] font-bold text-white" : "font-medium text-[var(--rail-item)] hover:bg-white/[0.07]", ].join(" ") } > {({ isActive }) => ( <> {item.label} )} ); } export default function AdminShell() { const { user, signOut } = useAuth(); const location = useLocation(); const account = user?.full_name || user?.email?.split("@")[0] || ""; return (
{/* rail first == right side in RTL */}
); } /** Shared page header for admin screens. * * The admin file sets its title at 34/800 rather than the product's 40 - an * administrative page carries more per screen and the smaller title leaves * the room for it. */ export function AdminHeader({ title, subtitle, action, }: { title: string; subtitle?: string; action?: React.ReactNode; }) { return (

{title}

{subtitle && (

{subtitle}

)}
{action}
); } /** The week/month/quarter/year switch. Full-height pills, per the admin file. */ export function RangeSwitch({ value, onChange, options = [ { days: 7, label: "أسبوع" }, { days: 30, label: "شهر" }, { days: 90, label: "٣ أشهر" }, { days: 365, label: "سنة" }, ], }: { value: number; onChange: (days: number) => void; options?: { days: number; label: string }[]; }) { return (
{options.map((o) => ( ))}
); }