'use client'; import React, { useState, useEffect } from 'react'; import Link from 'next/link'; import { usePathname, useRouter } from 'next/navigation'; import { Menu, Transition } from '@headlessui/react'; import { Fragment } from 'react'; import { useTheme } from 'next-themes'; import { HomeIcon, BuildingOfficeIcon, LinkIcon, Cog6ToothIcon, DocumentTextIcon, ChevronLeftIcon, ChevronRightIcon, UserCircleIcon, ArrowRightOnRectangleIcon, SunIcon, MoonIcon, } from '@heroicons/react/24/outline'; export interface MenuItem { id: string; label: string; href: string; icon: any; } interface SidebarRailProps { activeTab: string; onTabChange: (tab: string) => void; isExpanded: boolean; onToggle: () => void; menuItems: MenuItem[]; } export const SidebarRail: React.FC = ({ activeTab, onTabChange, isExpanded, onToggle, menuItems, }) => { const pathname = usePathname(); const router = useRouter(); const { theme, setTheme } = useTheme(); const [mounted, setMounted] = useState(false); useEffect(() => { setMounted(true); }, []); const handleLogout = () => { localStorage.removeItem('token'); localStorage.removeItem('user'); router.push('/login'); }; const toggleTheme = () => { setTheme(theme === 'dark' ? 'light' : 'dark'); }; return (
{/* Toggle Button - Floating on the border */} {/* Header com Logo */}
{/* Logo */}
A
{/* Título com animação */}
Aggios
{/* Separador removido para visual mais limpo */} {/* Navegação */}
{menuItems.map((item) => ( onTabChange(item.id)} isExpanded={isExpanded} /> ))}
{/* Separador antes do menu de usuário */}
{/* User Menu - Footer */}
SuperAdmin
{({ active }) => ( )} {({ active }) => ( Configurações )} {({ active }) => ( )}
{({ active }) => ( )}
); }; // Subcomponente do Botão (Essencial para a animação do texto) interface RailButtonProps { label: string; icon: React.ComponentType<{ className?: string }>; href: string; active: boolean; onClick: () => void; isExpanded: boolean; } const RailButton: React.FC = ({ label, icon: Icon, href, active, onClick, isExpanded }) => ( {/* Ícone */} {/* Lógica Mágica do Texto: Max-Width Transition */}
{label}
{/* Indicador de Ativo (Barra lateral pequena quando fechado) */} {active && !isExpanded && (
)} );