"use client"; import { useAuth } from "@/contexts/AuthContext"; import { useRouter } from "next/navigation"; import { useEffect } from "react"; import { Loading } from "@/components/ui/Loading"; import toast from "react-hot-toast"; import { Ticket, BarChart3 } from "lucide-react"; import { SharedSidebar, NavItem } from "@/components/shared/SharedSidebar"; import UserDropdown from "@/components/UserDropdown"; const EMPLOYE_NAV_ITEMS: NavItem[] = [ { label: "Dashboard", href: "/employe/dashboard", icon: , color: "green", }, { label: "Validation des Tickets", href: "/employe/verification", icon: , color: "emerald", }, ]; const EMPLOYE_ACTIVE_STYLES: Record = { green: "bg-gradient-to-r from-green-600 to-green-700 text-white shadow-lg shadow-green-500/30", emerald: "bg-gradient-to-r from-emerald-600 to-teal-600 text-white shadow-lg shadow-emerald-500/30", }; export default function EmployeLayout({ children, }: { children: React.ReactNode; }) { const { user, isAuthenticated, isLoading, logout } = useAuth(); const router = useRouter(); useEffect(() => { if (!isLoading && !isAuthenticated) { router.push("/login"); return; } if (isAuthenticated && user?.role !== "EMPLOYEE") { router.push("/"); toast.error("Accès refusé : rôle employé requis"); return; } }, [isLoading, isAuthenticated, user, router]); const handleLogout = async () => { await logout(); router.push("/login"); }; if (isLoading) { return (
); } if (!isAuthenticated || user?.role !== "EMPLOYEE") { return null; } return (
{/* Main Content */}
{/* Header */}
{/* Page Content */}
{children}
); }