'use client'; import { useState } from 'react'; import { Box, Container, Chip, Tooltip, IconButton, Menu, MenuItem, ListItemIcon, ListItemText, Avatar, Divider, } from '@mui/material'; import { MobileNav } from '../MobileNav/MobileNav'; import { TabBar } from '../TabBar/TabBar'; import { useMediaQuery } from '@/hooks/useMediaQuery'; import { ReactNode } from 'react'; import { useWebSocket } from '@/hooks/useWebSocket'; import { Wifi, WifiOff, People, AccountCircle, Settings, ChildCare, Group, Logout } from '@mui/icons-material'; import { useTranslation } from '@/hooks/useTranslation'; import { useRouter } from 'next/navigation'; import { useAuth } from '@/lib/auth/AuthContext'; interface AppShellProps { children: ReactNode; } export const AppShell = ({ children }: AppShellProps) => { const { t } = useTranslation('common'); const router = useRouter(); const { user, logout } = useAuth(); const isMobile = useMediaQuery('(max-width: 768px)'); const isTablet = useMediaQuery('(max-width: 1024px)'); const { isConnected, presence } = useWebSocket(); const [anchorEl, setAnchorEl] = useState(null); const handleMenuOpen = (event: React.MouseEvent) => { setAnchorEl(event.currentTarget); }; const handleMenuClose = () => { setAnchorEl(null); }; const handleNavigate = (path: string) => { handleMenuClose(); router.push(path); }; const handleLogout = async () => { handleMenuClose(); await logout(); router.push('/login'); }; return ( {!isMobile && } {/* Mobile Header Bar */} {isMobile && ( {/* Connection Status & Presence Indicator */} : } label={isConnected ? t('connection.live') : t('connection.offline')} size="small" color={isConnected ? 'success' : 'default'} sx={{ fontWeight: 600, }} /> {isConnected && presence.count > 1 && ( } label={presence.count} size="small" color="primary" sx={{ fontWeight: 600, }} /> )} {/* User Menu Button - Top Right */} {user?.name?.charAt(0).toUpperCase() || 'U'} handleNavigate('/settings')}> {t('navigation.settings')} handleNavigate('/children')}> {t('navigation.children')} handleNavigate('/family')}> {t('navigation.family')} {t('navigation.logout')} )} {/* Connection Status & Presence Indicator - Desktop Only */} {!isMobile && ( : } label={isConnected ? t('connection.live') : t('connection.offline')} size="small" color={isConnected ? 'success' : 'default'} sx={{ fontWeight: 600, boxShadow: 1, }} /> {isConnected && presence.count > 1 && ( } label={presence.count} size="small" color="primary" sx={{ fontWeight: 600, boxShadow: 1, }} /> )} )} {children} {isMobile && } ); };