"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 Link from "next/link"; import { usePathname } from "next/navigation"; import Logo from "@/components/Logo"; import UserDropdown from "@/components/UserDropdown"; export default function EmployeLayout({ children, }: { children: React.ReactNode; }) { const { user, isAuthenticated, isLoading, logout } = useAuth(); const router = useRouter(); const pathname = usePathname(); 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; } const navItems = [ { label: "Validation des Tickets", href: "/employe/verification", icon: , }, { label: "Dashboard", href: "/employe/dashboard", icon: , }, ]; const isActive = (href: string) => pathname === href; return (
{/* Sidebar */} {/* Main Content */}
{/* Header */}

Thé Tip Top - Espace Employé

{/* Page Content */}
{children}
); }