- Add dropdown menu with user avatar, name, and email in admin header - Add dropdown menu with user avatar, name, and email in employee header - Create admin profile page at /admin/profil - Create employee profile page at /employe/profil - Remove Profil link from admin sidebar (now in dropdown) - Fix header public display: hide for admin/employee on all pages - Use router.replace() instead of router.push() for login redirects to avoid history pollution - Simplify employe dashboard page: remove redundant auth checks handled by layout - Add click-outside-to-close functionality for dropdown menus 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
"use client";
|
|
|
|
import { usePathname } from "next/navigation";
|
|
import { useAuth } from "@/contexts/AuthContext";
|
|
import Header from "@/components/Header";
|
|
import Footer from "@/components/Footer";
|
|
import CookieConsent from "@/components/CookieConsent";
|
|
|
|
export default function LayoutClient({ children }: { children: React.ReactNode }) {
|
|
const pathname = usePathname();
|
|
const { user } = useAuth();
|
|
|
|
// Ne pas afficher Header/Footer dans l'espace admin et employé
|
|
const isAdminRoute = pathname?.startsWith("/admin");
|
|
const isEmployeRoute = pathname?.startsWith("/employe");
|
|
const isHomePage = pathname === "/";
|
|
const isLoginPage = pathname === "/login" || pathname === "/register";
|
|
|
|
// Vérifier si l'utilisateur est admin ou employé
|
|
const userRole = user?.role?.toUpperCase();
|
|
const isAdminOrEmployee = userRole === "ADMIN" || userRole === "EMPLOYEE";
|
|
|
|
// Ne pas afficher le header si:
|
|
// 1. On est sur une route admin/employé
|
|
// 2. On est sur login/register ET l'utilisateur est admin/employé (en cours de redirection)
|
|
if (isAdminRoute || isEmployeRoute || (isLoginPage && isAdminOrEmployee)) {
|
|
return <>{children}</>;
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<Header />
|
|
<main className={isHomePage ? "flex-1" : "flex-1 container mx-auto px-4 py-6 sm:px-6 lg:px-8"}>
|
|
{children}
|
|
</main>
|
|
<Footer />
|
|
<CookieConsent />
|
|
</>
|
|
);
|
|
}
|