55 lines
3.0 KiB
TypeScript
55 lines
3.0 KiB
TypeScript
import { ArchiveRestore, BookOpen, CircleDollarSign, Gauge, LayoutDashboard, Lightbulb, ListTodo, LogOut, Network, Settings2, ShieldCheck, Users } from "lucide-react";
|
||
import { Link, NavLink, Outlet } from "react-router";
|
||
import { useAuth } from "../auth/AuthContext";
|
||
import { useDeploymentProfile } from "../deployment/DeploymentProfileContext";
|
||
import { AdminCopyright } from "./AdminCopyright";
|
||
|
||
export const sections = [
|
||
{ id: "dashboard", to: "/admin", label: "نمای کلی", icon: Gauge },
|
||
{ id: "projects", to: "/admin/projects", label: "پروژهها", icon: ListTodo },
|
||
{ id: "projects", to: "/admin/archive", label: "بایگانی", icon: ArchiveRestore },
|
||
{ id: "reference-data", to: "/admin/reference-data", label: "مضامین و ارزشها", icon: Settings2 },
|
||
{ id: "ideas", to: "/admin/ideas", label: "ایدهها و دستاوردها", icon: Lightbulb },
|
||
{ id: "ecosystem", to: "/admin/ecosystem", label: "زیستبوم", icon: Network },
|
||
{ id: "financial", to: "/admin/financial", label: "اطلاعات مالی", icon: CircleDollarSign },
|
||
{ id: "content", to: "/admin/content", label: "انتشارات و رویدادها", icon: BookOpen },
|
||
{ id: "users", to: "/admin/users", label: "کاربران و دسترسیها", icon: Users },
|
||
{ id: "account", to: "/admin/account", label: "امنیت حساب", icon: ShieldCheck },
|
||
];
|
||
|
||
export function AppShell() {
|
||
const { user, logout } = useAuth();
|
||
const { profile } = useDeploymentProfile();
|
||
const visibleSections = sections.filter(section => profile.features.adminModules.includes(section.id));
|
||
return <div className="app-shell">
|
||
<aside className="sidebar">
|
||
<div className="brand-mark">
|
||
<img className="deployment-product-logo" src="/product-logo.svg" alt=""/>
|
||
<div><strong>{profile.company.shortName}</strong><small>{profile.branding.applicationTitle}</small></div>
|
||
</div>
|
||
<nav className="nav-list" aria-label="منوی اصلی">
|
||
{visibleSections.map(({ to, label, icon: Icon }) =>
|
||
<NavLink key={to} to={to} end={to === "/admin"} className={({ isActive }) => `nav-item ${isActive ? "active" : ""}`}>
|
||
<Icon size={19}/><span>{label}</span>
|
||
</NavLink>)}
|
||
</nav>
|
||
<div className="sidebar-user">
|
||
<div className="avatar">{user?.displayName?.slice(0, 1) ?? "ر"}</div>
|
||
<div><strong>{user?.displayName}</strong><small>{user?.roles.join("، ")}</small></div>
|
||
<button className="icon-button" onClick={() => void logout()} title="خروج"><LogOut size={18}/></button>
|
||
</div>
|
||
</aside>
|
||
<main className="main-area">
|
||
<header className="topbar">
|
||
<div><small>{profile.company.displayName}</small><h1>{profile.branding.adminTitle}</h1></div>
|
||
<div className="admin-topbar-actions">
|
||
<Link className="text-link" to="/dashboard"><LayoutDashboard size={17}/>بازگشت به میزکار</Link>
|
||
</div>
|
||
</header>
|
||
<div className="page-container"><Outlet /></div>
|
||
<AdminCopyright />
|
||
</main>
|
||
</div>;
|
||
}
|
||
|