All files / src/features/babies/components AddBabyDialog.tsx

100% Statements 8/8
100% Branches 2/2
100% Functions 2/2
100% Lines 7/7

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                        26x 26x 26x 6x         1x 1x 1x          
import { useTranslation } from 'react-i18next'
import { toast } from 'sonner'
import { useCreateBaby } from '../api/babies.hooks'
import { BabyEditorDialog } from './BabyEditorDialog'
 
export function AddBabyDialog({
  open,
  onOpenChange,
}: {
  open: boolean
  onOpenChange: (open: boolean) => void
}) {
  const { t } = useTranslation()
  const createBaby = useCreateBaby()
  if (!open) return null
  return (
    <BabyEditorDialog
      open
      onOpenChange={onOpenChange}
      onSave={async (values) => {
        await createBaby.mutateAsync(values)
        toast.success(t('babies.form.successToast'))
        onOpenChange(false)
      }}
    />
  )
}