307 lines
8.2 KiB
TypeScript
307 lines
8.2 KiB
TypeScript
"use client";
|
|
|
|
import {
|
|
BadgeCheck,
|
|
BarChart3,
|
|
Briefcase,
|
|
ChevronRight,
|
|
ClipboardList,
|
|
Clock3,
|
|
FileText,
|
|
Folder,
|
|
Globe2,
|
|
HelpCircle,
|
|
LayoutDashboard,
|
|
Settings,
|
|
Sparkles,
|
|
Star,
|
|
Users,
|
|
} from "lucide-react";
|
|
|
|
import {
|
|
Breadcrumb,
|
|
BreadcrumbItem,
|
|
BreadcrumbLink,
|
|
BreadcrumbList,
|
|
BreadcrumbPage,
|
|
BreadcrumbSeparator,
|
|
} from "@/components/ui/breadcrumb";
|
|
import {
|
|
Collapsible,
|
|
CollapsibleContent,
|
|
CollapsibleTrigger,
|
|
} from "@/components/ui/collapsible";
|
|
import { ScrollArea } from "@/components/ui/scroll-area";
|
|
import { Separator } from "@/components/ui/separator";
|
|
import {
|
|
Sidebar,
|
|
SidebarContent,
|
|
SidebarFooter,
|
|
SidebarGroup,
|
|
SidebarGroupContent,
|
|
SidebarGroupLabel,
|
|
SidebarHeader,
|
|
SidebarInset,
|
|
SidebarMenu,
|
|
SidebarMenuButton,
|
|
SidebarMenuItem,
|
|
SidebarMenuSub,
|
|
SidebarMenuSubButton,
|
|
SidebarMenuSubItem,
|
|
SidebarProvider,
|
|
SidebarRail,
|
|
SidebarTrigger,
|
|
} from "@/components/ui/sidebar";
|
|
import { cn } from "@/lib/utils";
|
|
|
|
type NavItem = {
|
|
label: string;
|
|
icon: React.ComponentType<React.SVGProps<SVGSVGElement>>;
|
|
href: string;
|
|
isActive?: boolean;
|
|
children?: NavItem[];
|
|
};
|
|
|
|
type NavGroup = {
|
|
title: string;
|
|
items: NavItem[];
|
|
defaultOpen?: boolean;
|
|
};
|
|
|
|
type SidebarData = {
|
|
logo: {
|
|
src: string;
|
|
alt: string;
|
|
title: string;
|
|
description: string;
|
|
};
|
|
navGroups: NavGroup[];
|
|
footerGroup: NavGroup;
|
|
};
|
|
|
|
const sidebarData: SidebarData = {
|
|
logo: {
|
|
src: "/block-media/shadcnblocks/block/logos/ShadcnBlocks-logo.svg",
|
|
alt: "پشتیبانییار",
|
|
title: "پشتیبانییار",
|
|
description: "میز خدمت مشتریان",
|
|
},
|
|
navGroups: [
|
|
{
|
|
title: "نمای کلی",
|
|
defaultOpen: true,
|
|
items: [
|
|
{
|
|
label: "داشبورد",
|
|
icon: LayoutDashboard,
|
|
href: "#",
|
|
isActive: true,
|
|
},
|
|
{ label: "تیکتها", icon: ClipboardList, href: "#" },
|
|
{ label: "صف SLA", icon: BarChart3, href: "#" },
|
|
],
|
|
},
|
|
{
|
|
title: "پایگاه دانش",
|
|
defaultOpen: true,
|
|
items: [
|
|
{
|
|
label: "مقالات فعال",
|
|
icon: Briefcase,
|
|
href: "#",
|
|
children: [
|
|
{ label: "ورود به سیستم", icon: FileText, href: "#" },
|
|
{ label: "صورتحساب", icon: FileText, href: "#" },
|
|
{ label: "یکپارچهسازی", icon: FileText, href: "#" },
|
|
],
|
|
},
|
|
{
|
|
label: "بایگانی",
|
|
icon: Folder,
|
|
href: "#",
|
|
children: [
|
|
{ label: "بایگانی ۱۴۰۳", icon: FileText, href: "#" },
|
|
{ label: "بایگانی ۱۴۰۲", icon: FileText, href: "#" },
|
|
],
|
|
},
|
|
],
|
|
},
|
|
{
|
|
title: "تیم پشتیبانی",
|
|
defaultOpen: false,
|
|
items: [
|
|
{ label: "کارشناسان", icon: Users, href: "#" },
|
|
{ label: "نوبت شیفت", icon: Clock3, href: "#" },
|
|
{ label: "ارجاعها", icon: BadgeCheck, href: "#" },
|
|
{ label: "بازبینی کیفیت", icon: Star, href: "#" },
|
|
],
|
|
},
|
|
{
|
|
title: "فضای کار",
|
|
defaultOpen: false,
|
|
items: [
|
|
{ label: "یکپارچهسازیها", icon: Globe2, href: "#" },
|
|
{ label: "اتوماسیون پاسخ", icon: Sparkles, href: "#" },
|
|
],
|
|
},
|
|
],
|
|
footerGroup: {
|
|
title: "پشتیبانی",
|
|
items: [
|
|
{ label: "مرکز راهنما", icon: HelpCircle, href: "#" },
|
|
{ label: "تنظیمات", icon: Settings, href: "#" },
|
|
],
|
|
},
|
|
};
|
|
|
|
const SidebarLogo = ({ logo }: { logo: SidebarData["logo"] }) => {
|
|
return (
|
|
<SidebarMenu>
|
|
<SidebarMenuItem>
|
|
<SidebarMenuButton size="lg">
|
|
<div className="flex aspect-square size-8 items-center justify-center rounded-sm bg-primary">
|
|
<img
|
|
src={logo.src}
|
|
alt={logo.alt}
|
|
className="size-6 text-primary-foreground invert dark:invert-0"
|
|
/>
|
|
</div>
|
|
<div className="flex flex-col gap-0.5 text-start leading-none">
|
|
<span className="font-medium">{logo.title}</span>
|
|
<span className="text-xs text-muted-foreground">
|
|
{logo.description}
|
|
</span>
|
|
</div>
|
|
</SidebarMenuButton>
|
|
</SidebarMenuItem>
|
|
</SidebarMenu>
|
|
);
|
|
};
|
|
|
|
const NavMenuItem = ({ item }: { item: NavItem }) => {
|
|
const Icon = item.icon;
|
|
const hasChildren = item.children && item.children.length > 0;
|
|
|
|
if (!hasChildren) {
|
|
return (
|
|
<SidebarMenuItem>
|
|
<SidebarMenuButton asChild isActive={item.isActive}>
|
|
<a href={item.href}>
|
|
<Icon className="size-4" />
|
|
<span>{item.label}</span>
|
|
</a>
|
|
</SidebarMenuButton>
|
|
</SidebarMenuItem>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Collapsible
|
|
asChild
|
|
defaultOpen={item.isActive}
|
|
className="group/collapsible"
|
|
>
|
|
<SidebarMenuItem>
|
|
<CollapsibleTrigger asChild>
|
|
<SidebarMenuButton isActive={item.isActive}>
|
|
<Icon className="size-4" />
|
|
<span>{item.label}</span>
|
|
<ChevronRight className="ms-auto size-4 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" />
|
|
</SidebarMenuButton>
|
|
</CollapsibleTrigger>
|
|
<CollapsibleContent>
|
|
<SidebarMenuSub>
|
|
{item.children!.map((child) => (
|
|
<SidebarMenuSubItem key={child.label}>
|
|
<SidebarMenuSubButton asChild isActive={child.isActive}>
|
|
<a href={child.href}>{child.label}</a>
|
|
</SidebarMenuSubButton>
|
|
</SidebarMenuSubItem>
|
|
))}
|
|
</SidebarMenuSub>
|
|
</CollapsibleContent>
|
|
</SidebarMenuItem>
|
|
</Collapsible>
|
|
);
|
|
};
|
|
|
|
const AppSidebar = ({ ...props }: React.ComponentProps<typeof Sidebar>) => {
|
|
return (
|
|
<Sidebar side="right" {...props}>
|
|
<SidebarHeader>
|
|
<SidebarLogo logo={sidebarData.logo} />
|
|
</SidebarHeader>
|
|
<SidebarContent className="overflow-hidden">
|
|
<ScrollArea className="min-h-0 flex-1">
|
|
{sidebarData.navGroups.map((group) => (
|
|
<SidebarGroup key={group.title}>
|
|
<SidebarGroupLabel>{group.title}</SidebarGroupLabel>
|
|
<SidebarGroupContent>
|
|
<SidebarMenu>
|
|
{group.items.map((item) => (
|
|
<NavMenuItem key={item.label} item={item} />
|
|
))}
|
|
</SidebarMenu>
|
|
</SidebarGroupContent>
|
|
</SidebarGroup>
|
|
))}
|
|
</ScrollArea>
|
|
</SidebarContent>
|
|
<SidebarFooter>
|
|
<SidebarGroup>
|
|
<SidebarGroupLabel>{sidebarData.footerGroup.title}</SidebarGroupLabel>
|
|
<SidebarGroupContent>
|
|
<SidebarMenu>
|
|
{sidebarData.footerGroup.items.map((item) => (
|
|
<NavMenuItem key={item.label} item={item} />
|
|
))}
|
|
</SidebarMenu>
|
|
</SidebarGroupContent>
|
|
</SidebarGroup>
|
|
</SidebarFooter>
|
|
<SidebarRail />
|
|
</Sidebar>
|
|
);
|
|
};
|
|
|
|
interface Sidebar4Props {
|
|
className?: string;
|
|
}
|
|
|
|
const Sidebar4 = ({ className }: Sidebar4Props) => {
|
|
return (
|
|
<SidebarProvider
|
|
dir="rtl"
|
|
lang="fa"
|
|
className={cn(className)}
|
|
>
|
|
<AppSidebar />
|
|
<SidebarInset>
|
|
<header className="flex h-16 shrink-0 items-center gap-2 border-b px-4">
|
|
<SidebarTrigger className="-ms-1" />
|
|
<Separator
|
|
orientation="vertical"
|
|
className="ms-2 data-[orientation=vertical]:h-4"
|
|
/>
|
|
<Breadcrumb>
|
|
<BreadcrumbList>
|
|
<BreadcrumbItem className="hidden md:block">
|
|
<BreadcrumbLink href="#">نمای کلی</BreadcrumbLink>
|
|
</BreadcrumbItem>
|
|
<BreadcrumbSeparator className="hidden md:block" />
|
|
<BreadcrumbItem>
|
|
<BreadcrumbPage>داشبورد</BreadcrumbPage>
|
|
</BreadcrumbItem>
|
|
</BreadcrumbList>
|
|
</Breadcrumb>
|
|
</header>
|
|
<div className="flex flex-1 flex-col gap-4 p-4">
|
|
<div className="min-h-[100vh] flex-1 rounded-xl bg-muted/50 md:min-h-min" />
|
|
</div>
|
|
</SidebarInset>
|
|
</SidebarProvider>
|
|
);
|
|
};
|
|
|
|
export { Sidebar4 };
|