Files
maternal-app/maternal-web/app/track/page.tsx
Andrei 26306d7ed8
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
Add Medicine and Activity trackers with voice command support
Added new tracking pages:
- Medicine tracker: track medication name, dosage, unit, route, and reason
- Activity tracker: track play, exercise, walks, music, reading, tummy time, etc.
- Both pages follow existing tracker patterns with recent activities list

Voice command improvements:
- Updated voice classification to support medicine and activity types
- Added detailed extraction fields for medicine (medicineName, dosage, unit, route, reason)
- Added detailed extraction fields for activity (activityType, duration, description)
- Enhanced unknown intent dialog with manual tracker selection
- Updated tracker options to match implemented pages (removed milestone)

Backend changes:
- Added MEDICINE and ACTIVITY to ActivityType enum
- Created migration V013 to add medicine/activity to database CHECK constraint
- Updated voice service prompts to include medicine and activity extraction

Frontend changes:
- Created /track/medicine page with full CRUD operations
- Created /track/activity page with full CRUD operations
- Added Medicine card to /track page with MedicalServices icon
- Updated VoiceFloatingButton unknown dialog with 4 tracker options

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-02 11:46:10 +00:00

96 lines
2.9 KiB
TypeScript

'use client';
import { Box, Typography, Grid, Card, CardContent, CardActionArea } from '@mui/material';
import { Restaurant, Hotel, BabyChangingStation, ChildCare, MedicalServices } from '@mui/icons-material';
import { useRouter } from 'next/navigation';
import { AppShell } from '@/components/layouts/AppShell/AppShell';
import { ProtectedRoute } from '@/components/common/ProtectedRoute';
export default function TrackPage() {
const router = useRouter();
const trackingOptions = [
{
title: 'Feeding',
icon: <Restaurant sx={{ fontSize: 48, color: 'primary.main' }} />,
path: '/track/feeding',
color: '#FFE4E1',
},
{
title: 'Sleep',
icon: <Hotel sx={{ fontSize: 48, color: 'info.main' }} />,
path: '/track/sleep',
color: '#E1F5FF',
},
{
title: 'Diaper',
icon: <BabyChangingStation sx={{ fontSize: 48, color: 'warning.main' }} />,
path: '/track/diaper',
color: '#FFF4E1',
},
{
title: 'Medicine',
icon: <MedicalServices sx={{ fontSize: 48, color: 'error.main' }} />,
path: '/track/medicine',
color: '#FFE8E8',
},
{
title: 'Activity',
icon: <ChildCare sx={{ fontSize: 48, color: 'success.main' }} />,
path: '/track/activity',
color: '#E8F5E9',
},
];
return (
<ProtectedRoute>
<AppShell>
<Box>
<Typography variant="h4" fontWeight="600" gutterBottom>
Track Activity
</Typography>
<Typography variant="body1" color="text.secondary" sx={{ mb: 4 }}>
Select an activity to track
</Typography>
<Grid container spacing={3}>
{trackingOptions.map((option) => (
<Grid item xs={12} sm={6} md={3} key={option.title}>
<Card
sx={{
height: '100%',
bgcolor: option.color,
'&:hover': {
transform: 'translateY(-4px)',
transition: 'transform 0.2s',
},
}}
>
<CardActionArea
onClick={() => router.push(option.path)}
sx={{
height: '100%',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
py: 4,
}}
>
<CardContent sx={{ textAlign: 'center' }}>
{option.icon}
<Typography variant="h6" fontWeight="600" sx={{ mt: 2 }}>
{option.title}
</Typography>
</CardContent>
</CardActionArea>
</Card>
</Grid>
))}
</Grid>
</Box>
</AppShell>
</ProtectedRoute>
);
}