diff --git a/components/admin/Sidebar.tsx b/components/admin/Sidebar.tsx
index a3a288c..424bd0e 100644
--- a/components/admin/Sidebar.tsx
+++ b/components/admin/Sidebar.tsx
@@ -1,154 +1,70 @@
"use client";
-import Link from "next/link";
-import { usePathname } from "next/navigation";
import {
LayoutDashboard,
Users,
Ticket,
BarChart3,
Gift,
- Menu,
- X,
Trophy,
} from "lucide-react";
-import { useState } from "react";
-import Logo from "@/components/Logo";
+import { SharedSidebar, NavItem } from "@/components/shared/SharedSidebar";
-interface NavItem {
- label: string;
- href: string;
- icon: React.ReactNode;
- color: string;
-}
+const ADMIN_NAV_ITEMS: NavItem[] = [
+ {
+ label: "Dashboard",
+ href: "/admin/dashboard",
+ icon:
,
+ color: "darkblue",
+ },
+ {
+ label: "Utilisateurs",
+ href: "/admin/utilisateurs",
+ icon:
,
+ color: "blue",
+ },
+ {
+ label: "Tickets",
+ href: "/admin/tickets",
+ icon:
,
+ color: "emerald",
+ },
+ {
+ label: "Lots & Prix",
+ href: "/admin/lots",
+ icon:
,
+ color: "purple",
+ },
+ {
+ label: "Données Marketing",
+ href: "/admin/marketing-data",
+ icon:
,
+ color: "indigo",
+ },
+ {
+ label: "Tirages",
+ href: "/admin/tirages",
+ icon:
,
+ color: "amber",
+ },
+];
+
+const ADMIN_ACTIVE_STYLES: Record
= {
+ darkblue: "bg-gradient-to-r from-[#1e3a5f] to-[#2d5a8f] text-white shadow-lg shadow-blue-900/30",
+ blue: "bg-gradient-to-r from-blue-600 to-indigo-600 text-white shadow-lg shadow-blue-500/30",
+ emerald: "bg-gradient-to-r from-emerald-600 to-teal-600 text-white shadow-lg shadow-emerald-500/30",
+ purple: "bg-gradient-to-r from-purple-600 to-pink-600 text-white shadow-lg shadow-purple-500/30",
+ indigo: "bg-gradient-to-r from-indigo-600 to-purple-600 text-white shadow-lg shadow-indigo-500/30",
+ amber: "bg-gradient-to-r from-amber-500 to-orange-600 text-white shadow-lg shadow-amber-500/30",
+};
export default function Sidebar() {
- const pathname = usePathname();
- const [isOpen, setIsOpen] = useState(false);
-
- const navItems: NavItem[] = [
- {
- label: "Dashboard",
- href: "/admin/dashboard",
- icon: ,
- color: "darkblue",
- },
- {
- label: "Utilisateurs",
- href: "/admin/utilisateurs",
- icon: ,
- color: "blue",
- },
- {
- label: "Tickets",
- href: "/admin/tickets",
- icon: ,
- color: "emerald",
- },
- {
- label: "Lots & Prix",
- href: "/admin/lots",
- icon: ,
- color: "purple",
- },
- {
- label: "Données Marketing",
- href: "/admin/marketing-data",
- icon: ,
- color: "indigo",
- },
- {
- label: "Tirages",
- href: "/admin/tirages",
- icon: ,
- color: "amber",
- },
- ];
-
- const isActive = (href: string) => {
- return pathname === href;
- };
-
- const getActiveStyles = (color: string) => {
- const styles: Record = {
- darkblue: "bg-gradient-to-r from-[#1e3a5f] to-[#2d5a8f] text-white shadow-lg shadow-blue-900/30",
- blue: "bg-gradient-to-r from-blue-600 to-indigo-600 text-white shadow-lg shadow-blue-500/30",
- emerald: "bg-gradient-to-r from-emerald-600 to-teal-600 text-white shadow-lg shadow-emerald-500/30",
- purple: "bg-gradient-to-r from-purple-600 to-pink-600 text-white shadow-lg shadow-purple-500/30",
- indigo: "bg-gradient-to-r from-indigo-600 to-purple-600 text-white shadow-lg shadow-indigo-500/30",
- amber: "bg-gradient-to-r from-amber-500 to-orange-600 text-white shadow-lg shadow-amber-500/30",
- };
- return styles[color] || styles.blue;
- };
-
return (
- <>
- {/* Mobile menu button */}
-
-
- {/* Overlay for mobile */}
- {isOpen && (
- setIsOpen(false)}
- />
- )}
-
- {/* Sidebar */}
-
- >
+
);
}
diff --git a/components/shared/SharedSidebar.tsx b/components/shared/SharedSidebar.tsx
new file mode 100644
index 0000000..7acf3b7
--- /dev/null
+++ b/components/shared/SharedSidebar.tsx
@@ -0,0 +1,102 @@
+"use client";
+
+import Link from "next/link";
+import { usePathname } from "next/navigation";
+import { Menu, X } from "lucide-react";
+import { useState } from "react";
+import Logo from "@/components/Logo";
+
+export interface NavItem {
+ label: string;
+ href: string;
+ icon: React.ReactNode;
+ color: string;
+}
+
+export interface SidebarProps {
+ navItems: NavItem[];
+ title: string;
+ subtitle: string;
+ activeStyles: Record
;
+}
+
+export function SharedSidebar({ navItems, title, subtitle, activeStyles }: SidebarProps) {
+ const pathname = usePathname();
+ const [isOpen, setIsOpen] = useState(false);
+
+ const isActive = (href: string) => pathname === href;
+
+ const getActiveStyles = (color: string) => {
+ return activeStyles[color] || activeStyles[Object.keys(activeStyles)[0]];
+ };
+
+ return (
+ <>
+ {/* Mobile menu button */}
+
+
+ {/* Overlay for mobile */}
+ {isOpen && (
+ setIsOpen(false)}
+ />
+ )}
+
+ {/* Sidebar */}
+
+ >
+ );
+}