import { useState } from 'react'
import {
classifyRecordError,
setAnimalArchived,
type RecordFailureKind,
} from '@faunosteo/supabase'
import Button from '@/components/ui/Button'
import Dialog from '@/components/ui/Dialog'
import Notice from '@/components/ui/Notice'
import { getSupabaseClient } from '@/lib/supabase'
import { useT } from '@/i18n/useT'
export interface ArchiveAnimalDialogProps {
open: boolean
animalId: string
onClose: () => void
/** Called once the server archived the animal; the page then closes the dialog. */
onArchived: () => void
}
/**
* Confirmation before archiving an animal (contract ยง7.1): its relations are
* kept and frozen, no client is archived. Closing it is never a
* confirmation, and while the request runs it refuses to close.
*/
export default function ArchiveAnimalDialog({
open,
animalId,
onClose,
onArchived,
}: ArchiveAnimalDialogProps) {
const t = useT()
const [pending, setPending] = useState(false)
const [failure, setFailure] = useState