API Services Created: - lib/api/children.ts: Full CRUD operations for children management - lib/api/families.ts: Family member management and invitations - lib/api/tracking.ts: Activity tracking (feeding, sleep, diaper, etc.) Children Page Implementation: - Fetch and display children from backend API - Add/Edit child with modal dialog (ChildDialog component) - Delete child with confirmation (DeleteConfirmDialog component) - Age calculation from birthDate - Loading states and error handling - Responsive card grid layout - Gender-based avatar colors - Empty state for no children AuthContext Updates: - Added families array to User interface - Includes familyId for API calls Components: - components/children/ChildDialog.tsx: Form for add/edit child - components/children/DeleteConfirmDialog.tsx: Delete confirmation All components use Material-UI theme and include proper TypeScript types 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
'use client';
|
|
|
|
import {
|
|
Dialog,
|
|
DialogTitle,
|
|
DialogContent,
|
|
DialogActions,
|
|
Button,
|
|
Typography,
|
|
} from '@mui/material';
|
|
import { Warning } from '@mui/icons-material';
|
|
|
|
interface DeleteConfirmDialogProps {
|
|
open: boolean;
|
|
onClose: () => void;
|
|
onConfirm: () => void;
|
|
childName: string;
|
|
isLoading?: boolean;
|
|
}
|
|
|
|
export function DeleteConfirmDialog({
|
|
open,
|
|
onClose,
|
|
onConfirm,
|
|
childName,
|
|
isLoading = false,
|
|
}: DeleteConfirmDialogProps) {
|
|
return (
|
|
<Dialog open={open} onClose={onClose} maxWidth="xs" fullWidth>
|
|
<DialogTitle sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
|
<Warning color="warning" />
|
|
Confirm Delete
|
|
</DialogTitle>
|
|
<DialogContent>
|
|
<Typography variant="body1">
|
|
Are you sure you want to delete <strong>{childName}</strong>?
|
|
</Typography>
|
|
<Typography variant="body2" color="text.secondary" sx={{ mt: 2 }}>
|
|
This action cannot be undone. All associated data will be permanently removed.
|
|
</Typography>
|
|
</DialogContent>
|
|
<DialogActions>
|
|
<Button onClick={onClose} disabled={isLoading}>
|
|
Cancel
|
|
</Button>
|
|
<Button onClick={onConfirm} color="error" variant="contained" disabled={isLoading}>
|
|
{isLoading ? 'Deleting...' : 'Delete'}
|
|
</Button>
|
|
</DialogActions>
|
|
</Dialog>
|
|
);
|
|
}
|