import { useState, useEffect } from 'react'; import { Bell, Settings, User, Plus, Search, Home, FileText, CheckCircle, LogOut, PanelLeft, PanelLeftClose } from 'lucide-react'; 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 { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from '@/components/ui/alert-dialog'; import { useAuth } from '@/contexts/AuthContext'; import royalEnfieldLogo from '@/assets/images/royal_enfield_logo.png'; interface PageLayoutProps { children: React.ReactNode; currentPage?: string; onNavigate?: (page: string) => void; onNewRequest?: () => void; onLogout?: () => void; } export function PageLayout({ children, currentPage = 'dashboard', onNavigate, onNewRequest, onLogout }: PageLayoutProps) { const [sidebarOpen, setSidebarOpen] = useState(false); const [showLogoutDialog, setShowLogoutDialog] = useState(false); const { user } = useAuth(); // Get user initials for avatar const getUserInitials = () => { if (user?.displayName) { const names = user.displayName.split(' ').filter(Boolean); if (names.length >= 2) { return `${names[0]?.[0] || ''}${names[names.length - 1]?.[0] || ''}`.toUpperCase(); } return user.displayName.substring(0, 2).toUpperCase(); } if (user?.email) { return user.email.substring(0, 2).toUpperCase(); } return 'U'; }; const menuItems = [ { id: 'dashboard', label: 'Dashboard', icon: Home }, { id: 'my-requests', label: 'My Requests', icon: User }, { id: 'open-requests', label: 'Open Requests', icon: FileText }, { id: 'closed-requests', label: 'Closed Requests', icon: CheckCircle }, ]; const toggleSidebar = () => { setSidebarOpen(!sidebarOpen); }; // Handle responsive behavior: sidebar open on desktop, closed on mobile useEffect(() => { const handleResize = () => { // 768px is the md breakpoint in Tailwind if (window.innerWidth >= 768) { setSidebarOpen(true); // Always open on desktop } else { setSidebarOpen(false); // Closed by default on mobile } }; // Set initial state handleResize(); // Add event listener window.addEventListener('resize', handleResize); // Cleanup return () => window.removeEventListener('resize', handleResize); }, []); return (
RE-REQ-001 needs approval
SLA expires in 2 hours
New comment on RE-REQ-003
From John Doe - 5 min ago