import { useState } from 'react' import { Modal } from '@/components/ui/Modal' import { Alert } from '@/components/ui/Alert' import { Button } from '@/components/ui/Button' import { errorMessage } from '@/lib/api' import { useDeletePlant, type Plant } from '@/lib/plants' /** * Confirmation dialog for deleting a custom plant. A plant still used by * plantings is refused by the server (409 PLANT_IN_USE); we surface that * message inline rather than pretending it worked. */ export function DeletePlantModal({ plant, onClose }: { plant: Plant; onClose: () => void }) { const deletion = useDeletePlant() const [error, setError] = useState(null) async function onConfirm() { setError(null) try { await deletion.mutateAsync(plant.id) onClose() } catch (err) { setError(errorMessage(err, 'Could not delete the plant.')) } } return (

Delete {plant.name} from your catalog? This can't be undone.

{error && {error}}
) }