// Caminho: components/layout/DashboardLayout.tsx "use client"; import type React from "react"; import { useState, useEffect } from "react"; import { useRouter, usePathname } from "next/navigation"; import Link from "next/link"; import { autenticacaoApi } from '@/services/autenticacaoApi'; // Importamos o serviço correto // Importe todos os componentes UI e ícones que você usa import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Badge } from "@/components/ui/badge"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog"; import { Search, Bell, LogOut, ChevronLeft, ChevronRight, LucideIcon } from "lucide-react"; // Tipos para as props do nosso layout genérico export interface MenuItem { href: string; icon: LucideIcon; label: string; } export interface UserProfile { name: string; secondaryText: string; // Pode ser o email, departamento, especialidade, etc. avatarFallback: string; } interface DashboardLayoutProps { children: React.ReactNode; menuItems: MenuItem[]; userProfile: UserProfile | null; } export default function DashboardLayout({ children, menuItems, userProfile }: DashboardLayoutProps) { const [sidebarCollapsed, setSidebarCollapsed] = useState(false); const [showLogoutDialog, setShowLogoutDialog] = useState(false); const router = useRouter(); const pathname = usePathname(); // Lógica de responsividade (idêntica para todos) useEffect(() => { const handleResize = () => { if (window.innerWidth < 1024) { setSidebarCollapsed(true); } else { setSidebarCollapsed(false); } }; handleResize(); window.addEventListener("resize", handleResize); return () => window.removeEventListener("resize", handleResize); }, []); // Funções de logout (idênticas para todos) const handleLogout = () => setShowLogoutDialog(true); const confirmLogout = async () => { try { await autenticacaoApi.logout(); } catch (error) { console.error("Falha ao fazer logout no servidor:", error); } finally { setShowLogoutDialog(false); router.push("/"); // Redireciona para a home page } }; const cancelLogout = () => setShowLogoutDialog(false); if (!userProfile) { return
{userProfile.name}
{userProfile.secondaryText}