'use client'; import { useState } from 'react'; import { Box, Card, CardActionArea, CardContent, Typography, TextField, Button, Alert, MenuItem, } from '@mui/material'; import { FamilyRestroom, PersonAdd } from '@mui/icons-material'; export interface ChildData { name: string; birthDate: string; gender: 'male' | 'female' | 'other'; } interface FamilySetupStepProps { onCreateFamily: (childData: ChildData) => Promise; onJoinFamily: (shareCode: string) => Promise; loading: boolean; error: string; t: (key: string) => string; } export function FamilySetupStep({ onCreateFamily, onJoinFamily, loading, error, t, }: FamilySetupStepProps) { const [choice, setChoice] = useState<'create' | 'join' | null>(null); const [shareCode, setShareCode] = useState(''); const [childName, setChildName] = useState(''); const [childBirthDate, setChildBirthDate] = useState(''); const [childGender, setChildGender] = useState<'male' | 'female' | 'other'>('other'); if (choice === 'create') { return ( {t('child.title')} {t('child.subtitle')} {error && ( {error} )} setChildName(e.target.value)} margin="normal" required disabled={loading} InputProps={{ sx: { borderRadius: 3 }, }} /> setChildBirthDate(e.target.value)} margin="normal" required disabled={loading} InputLabelProps={{ shrink: true, }} InputProps={{ sx: { borderRadius: 3 }, }} /> setChildGender(e.target.value as 'male' | 'female' | 'other')} margin="normal" disabled={loading} InputProps={{ sx: { borderRadius: 3 }, }} > {t('child.genders.male')} {t('child.genders.female')} {t('child.genders.preferNotToSay')} ); } if (choice === 'join') { return ( Join Existing Family Enter the family code to join an existing family {error && ( {error} )} setShareCode(e.target.value.toUpperCase())} margin="normal" placeholder="ABC123DEF" helperText="Ask your family admin for the code" required disabled={loading} InputProps={{ sx: { borderRadius: 3 }, }} /> You'll be added as a viewer by default. The admin can change your role later. ); } return ( Choose Your Setup Start tracking or join an existing family {error && ( {error} )} setChoice('create')} sx={{ p: 2 }}> Create New Family Start tracking for your child. Invite family members later. setChoice('join')} sx={{ p: 2 }}> Join Existing Family Enter family code to join. Access shared tracking. ); }