diff --git a/components/layout/nav-item.tsx b/components/layout/nav-item.tsx new file mode 100644 index 0000000..07b48b7 --- /dev/null +++ b/components/layout/nav-item.tsx @@ -0,0 +1,24 @@ +import Link from "next/link"; + +interface NavItemProps { + href: string; + icon: React.ElementType; + children: React.ReactNode; + onClick?: () => void; +} + +export const NavItem: React.FC = ({ + href, + icon: Icon, + children, + onClick, +}) => ( + + + {children} + +); diff --git a/components/layout/sidebar.tsx b/components/layout/sidebar.tsx index 042856d..5ac09fc 100644 --- a/components/layout/sidebar.tsx +++ b/components/layout/sidebar.tsx @@ -1,7 +1,6 @@ "use client"; -import { fetchData } from '@/lib/data-service'; - +import { fetchData } from "@/lib/data-service"; import { useState } from "react"; import Link from "next/link"; import { useRouter } from "next/navigation"; @@ -16,25 +15,39 @@ import { Menu, } from "lucide-react"; -interface NavItemProps { +import { NavItem } from "./nav-item"; + +interface SidebarItem { + name: string; href: string; icon: React.ElementType; - children: React.ReactNode; - onClick?: () => void; } -const NavItem = ({ href, icon: Icon, children, onClick }: NavItemProps) => ( - - - {children} - -); +interface SidebarSection { + title: string; + items: SidebarItem[]; +} -function Sidebar() { +const sidebarConfig: SidebarSection[] = [ + { + title: "Overview", + items: [ + { name: "Dashboard", href: "/dashboard", icon: Home }, + { name: "Orders", href: "/dashboard/orders", icon: Package }, + ], + }, + { + title: "Management", + items: [ + { name: "Products", href: "/dashboard/products", icon: Box }, + { name: "Shipping", href: "/dashboard/shipping", icon: Truck }, + { name: "Storefront", href: "/dashboard/storefront", icon: Settings }, + ], + }, +]; + + +const Sidebar: React.FC = () => { const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false); const router = useRouter(); @@ -49,7 +62,8 @@ function Sidebar() { if (!res.ok) throw new Error("Logout failed"); - document.cookie = "authToken=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT;"; + document.cookie = + "authToken=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT;"; router.push("/login"); } catch (error) { console.error("Logout error:", error); @@ -58,14 +72,7 @@ function Sidebar() { return ( <> - - + {/* Sidebar Navigation */} + {/* Mobile Menu Overlay */} {isMobileMenuOpen && (
); -} +}; export default Sidebar;