Files
maternal-app/maternal-web/components/layouts/AppShell/AppShell.tsx
Andrei e8cf7d7ab6
Some checks failed
CI/CD Pipeline / Lint and Test (push) Has been cancelled
CI/CD Pipeline / E2E Tests (push) Has been cancelled
CI/CD Pipeline / Build Application (push) Has been cancelled
feat: Complete high-priority frontend features - accessibility and UX
**Error Boundaries (VERIFIED COMPLETE)**
- Comprehensive ErrorBoundary component already implemented in components/common/ErrorBoundary.tsx
- Features: Recovery UI, error logging, isolated error boundaries, development error details
- Global error boundary in root layout
- Page-level error boundaries in AI Assistant and dashboard
- Error tracking integration ready for Sentry

**Touch Target Sizes (WCAG 2.5.5 Compliance)**
- Fixed user menu IconButton: increased from 32x32px to 44x44px minimum (medium size)
- Created lib/utils/touchTargets.ts with accessibility utilities:
  * MINIMUM_TOUCH_TARGET = 44px (iOS/WCAG standard)
  * RECOMMENDED_TOUCH_TARGET = 48px (Android Material Design)
  * Helper functions: withTouchTarget(), validateTouchTarget()
  * Component-specific guidelines for IconButton, Button, FAB, Chip, etc.
- Verified existing components meet standards:
  * Quick action buttons: 140x140px ✓
  * Bottom navigation: 64px height ✓
  * Voice FAB: 56x56px ✓
  * Voice button in tab bar: 48x48px ✓

**AI Conversation History (VERIFIED COMPLETE)**
- Comprehensive conversation management already implemented in AIChatInterface.tsx
- Features verified:
  * Full conversation list with drawer (mobile) and sidebar (desktop)
  * Load conversations from backend API
  * Load individual conversation messages with scrolling
  * Auto-scroll to bottom on new messages
  * Conversation groups with collapsible organization
  * Delete conversations with confirmation
  * Context menu for conversation management
  * Thinking messages animation
  * Markdown rendering for AI responses
- Updated implementation-gaps.md to reflect completion status

**Documentation Updates**
- Updated docs/implementation-gaps.md:
  * Marked Conversation History as COMPLETED
  * Updated AI Assistant UI section with detailed implementation notes
  * Moved remaining features (Streaming Responses, Suggested Follow-Ups, AI Response Feedback UI) to "Remaining Features" section

**Impact**
- Error boundaries prevent full app crashes and provide graceful recovery
- Touch target sizes meet WCAG 2.5.5 (AAA) and mobile platform guidelines
- Conversation history enables contextual AI interactions with full persistence

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-03 22:10:47 +00:00

201 lines
5.6 KiB
TypeScript

'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 | HTMLElement>(null);
const handleMenuOpen = (event: React.MouseEvent<HTMLElement>) => {
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 (
<Box sx={{
display: 'flex',
flexDirection: 'column',
minHeight: '100vh',
bgcolor: 'background.default',
pb: '64px', // Space for tab bar on both mobile and desktop
}}>
{/* Header Bar - Both Mobile and Desktop */}
<Box
sx={{
position: 'fixed',
top: 0,
left: 0,
right: 0,
height: 48,
bgcolor: 'background.paper',
borderBottom: '1px solid',
borderColor: 'divider',
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
px: 2,
zIndex: 1200,
boxShadow: 1,
}}
>
{/* Connection Status & Presence Indicator */}
<Box
sx={{
display: 'flex',
gap: 1,
}}
>
<Tooltip title={isConnected ? t('connection.syncActive') : t('connection.syncDisconnected')}>
<Chip
icon={isConnected ? <Wifi /> : <WifiOff />}
label={isConnected ? t('connection.live') : t('connection.offline')}
size="small"
color={isConnected ? 'success' : 'default'}
sx={{
fontWeight: 600,
}}
/>
</Tooltip>
{isConnected && presence.count > 1 && (
<Tooltip title={t('connection.familyMembersOnline', { count: presence.count })}>
<Chip
icon={<People />}
label={presence.count}
size="small"
color="primary"
sx={{
fontWeight: 600,
}}
/>
</Tooltip>
)}
</Box>
{/* User Menu Button - Top Right */}
<IconButton
onClick={handleMenuOpen}
size="medium"
aria-label="user menu"
aria-controls={anchorEl ? 'user-menu' : undefined}
aria-haspopup="true"
aria-expanded={anchorEl ? 'true' : undefined}
sx={{
minWidth: 44,
minHeight: 44,
}}
>
<Avatar
sx={{
width: 36,
height: 36,
bgcolor: 'primary.main',
fontSize: '0.875rem',
}}
>
{user?.name?.charAt(0).toUpperCase() || 'U'}
</Avatar>
</IconButton>
<Menu
id="user-menu"
anchorEl={anchorEl}
open={Boolean(anchorEl)}
onClose={handleMenuClose}
onClick={handleMenuClose}
transformOrigin={{ horizontal: 'right', vertical: 'top' }}
anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
sx={{
mt: 1,
}}
>
<MenuItem onClick={() => handleNavigate('/settings')}>
<ListItemIcon>
<Settings fontSize="small" />
</ListItemIcon>
<ListItemText>{t('navigation.settings')}</ListItemText>
</MenuItem>
<MenuItem onClick={() => handleNavigate('/children')}>
<ListItemIcon>
<ChildCare fontSize="small" />
</ListItemIcon>
<ListItemText>{t('navigation.children')}</ListItemText>
</MenuItem>
<MenuItem onClick={() => handleNavigate('/family')}>
<ListItemIcon>
<Group fontSize="small" />
</ListItemIcon>
<ListItemText>{t('navigation.family')}</ListItemText>
</MenuItem>
<Divider />
<MenuItem onClick={handleLogout}>
<ListItemIcon>
<Logout fontSize="small" color="error" />
</ListItemIcon>
<ListItemText>{t('navigation.logout')}</ListItemText>
</MenuItem>
</Menu>
</Box>
<Container
maxWidth={isTablet ? 'md' : 'lg'}
sx={{
flex: 1,
px: { xs: 2, md: 3 },
py: 3,
pt: '64px', // Add top padding for header bar on both mobile and desktop
}}
>
{children}
</Container>
<TabBar />
</Box>
);
};