import { useState } from 'react'; import { deleteClient } from '../apiClients'; export function useClientDelete(onDeleted?: (uuid: string) => void) { const [showDialog, setShowDialog] = useState(false); const [deleteClientId, setDeleteClientId] = useState(null); // Details-Modal separat im Parent verwalten! const handleDelete = (uuid: string) => { setDeleteClientId(uuid); setShowDialog(true); }; const confirmDelete = async () => { if (deleteClientId) { await deleteClient(deleteClientId); setShowDialog(false); if (onDeleted) onDeleted(deleteClientId); setDeleteClientId(null); } }; const cancelDelete = () => { setShowDialog(false); setDeleteClientId(null); }; return { showDialog, deleteClientId, handleDelete, confirmDelete, cancelDelete, }; }