"use client"; import { ArrowRight, BadgeCheck, BarChart3, Briefcase, ChevronRight, ChevronsUpDown, ClipboardList, Clock3, FileText, Folder, Globe2, HelpCircle, LayoutDashboard, LogOut, Settings, Sparkles, Star, User, Users, } from "lucide-react"; import * as React from "react"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from "@/components/ui/breadcrumb"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Separator } from "@/components/ui/separator"; import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarProvider, SidebarRail, SidebarTrigger, } from "@/components/ui/sidebar"; import { cn } from "@/lib/utils"; // Base nav item - used by simple sidebars type NavItem = { label: string; icon: React.ComponentType>; href: string; isActive?: boolean; // Optional children for submenus (Sidebar3+) children?: NavItem[]; }; // Nav group with optional collapsible state type NavGroup = { title: string; items: NavItem[]; // Optional: default collapsed state (Sidebar2+) defaultOpen?: boolean; }; // User data for footer (Sidebar6+) type UserData = { name: string; email: string; avatar: string; }; // Complete sidebar data structure type SidebarData = { // Logo/branding (all sidebars) logo: { src: string; alt: string; title: string; description: string; }; // Main navigation groups (all sidebars) navGroups: NavGroup[]; // Footer navigation group (all sidebars) footerGroup: NavGroup; // User data for user footer (Sidebar6+) user?: UserData; // Workspaces for switcher (Sidebar7+) workspaces?: Array<{ id: string; name: string; logo: string; plan: string; }>; // Currently active workspace (Sidebar7+) activeWorkspace?: string; }; // Shared sidebar data - works with all sidebar variations const sidebarData: SidebarData = { logo: { src: "/block-media/shadcnblocks/block/logos/ShadcnBlocks-logo.svg", alt: "وندوک", title: "وندوک", description: "CRM فروش B2B", }, navGroups: [ { title: "نمای کلی", defaultOpen: true, items: [ { label: "داشبورد", icon: LayoutDashboard, href: "#", isActive: true, }, { label: "فعالیت‌ها", icon: ClipboardList, href: "#" }, { label: "قیف فروش", 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: "#" }, ], }, user: { name: "علی رضایی", email: "ali@example.com", avatar: "/block-media/shadcnblocks/block/avatar-5.webp", }, workspaces: [ { id: "1", name: "ShadcnBlocks", logo: "/block-media/shadcnblocks/block/logos/ShadcnBlocks-logo.svg", plan: "سازمانی", }, { id: "2", name: "قالب‌های وندوک", logo: "/block-media/shadcnblocks/block/logos/ShadcnBlocks-logo.svg", plan: "تیم فروش در حال رشد", }, { id: "3", name: "ماژول‌های وندوک", logo: "/block-media/shadcnblocks/block/logos/ShadcnBlocks-logo.svg", plan: "آزمایشی", }, ], activeWorkspace: "1", }; const SidebarLogo = ({ logo }: { logo: SidebarData["logo"] }) => { return (
{logo.alt}
{logo.title} {logo.description}
); }; const NavUser = ({ user }: { user: UserData }) => { return ( {user.name .split(" ") .map((n) => n[0]) .join("")}
{user.name} {user.email}
{user.name .split(" ") .map((n) => n[0]) .join("")}
{user.name} {user.email}
حساب کاربری خروج
); }; const AppSidebar = ({ ...props }: React.ComponentProps) => { const [activeItem, setActiveItem] = React.useState(null); // Get all items with children for drill-down const drillableItems = sidebarData.navGroups.flatMap((group) => group.items.filter((item) => item.children && item.children.length > 0), ); const handleItemClick = (item: NavItem) => { if (item.children && item.children.length > 0) { setActiveItem(item); } }; const handleBackToMain = () => { setActiveItem(null); }; // Main view - show all nav groups if (!activeItem) { return ( {sidebarData.navGroups.map((group) => ( {group.title} {group.items.map((item) => { const Icon = item.icon; const hasChildren = item.children && item.children.length > 0; return ( {hasChildren ? ( handleItemClick(item)} > {item.label} ) : ( {item.label} )} ); })} ))} {sidebarData.user && } ); } // Drill-down view - show sub-items const Icon = activeItem.icon; return (
{activeItem.label}
{activeItem.children!.map((child) => { const ChildIcon = child.icon; return ( {child.label} ); })} {sidebarData.user && }
); }; interface Sidebar21Props { className?: string; } const Sidebar21 = ({ className }: Sidebar21Props) => { return (
نمای کلی داشبورد
); }; export { Sidebar21 };