Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 28x 28x 28x 35x 35x | import { useTranslation } from 'react-i18next'
import { useAgeLabel } from '@/hooks/useAgeLabel'
import type { Baby } from '@/features/babies/api/babies.schemas'
import { cn } from '@/lib/utils'
import { babyAvatarAppearance, babyInitials } from '@/shared/utils/babyAvatarColor'
import { SelectorCardGroup } from './SelectorCardGroup'
interface BabyPickerStepProps {
babies: Baby[]
value: string | null
onSelect: (babyId: string) => void
}
// First step shared by the vaccine/appointment/milestone "Add" wizards when the
// household has more than one baby — skipped entirely (see soleBaby()) otherwise.
export function BabyPickerStep({ babies, value, onSelect }: BabyPickerStepProps) {
const { t } = useTranslation()
const ageLabel = useAgeLabel()
return (
<div className="animate-fade-in-up space-y-4">
<p className="text-sm text-ink-muted">{t('babies.picker.subtitle')}</p>
<SelectorCardGroup
layout="vertical"
value={value ?? ''}
onValueChange={onSelect}
options={babies.map((baby) => {
const avatarAppearance = babyAvatarAppearance(baby.id, baby.avatarColor)
return {
value: baby.id,
label: baby.name,
description: ageLabel(baby.birthDate),
media: (
<span
className={cn(
'flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-full text-sm font-black',
avatarAppearance.className,
)}
style={avatarAppearance.style}
>
{babyInitials(baby.name)}
</span>
),
}
})}
/>
</div>
)
}
|