'use client'; import { useState } from 'react'; import { Trash2 } from 'lucide-react'; import { deleteDocumentServer } from '@/app/actions/appwrite'; export const DeleteButton = ({ collectionId, documentId, entityAlias }: { collectionId: string, documentId: string, entityAlias: string }) => { const [isDeleting, setIsDeleting] = useState(false); const handleDelete = async () => { if (!window.confirm("¿Estás seguro de que deseas eliminar este registro? Esta acción es irreversible.")) { return; } setIsDeleting(true); const res = await deleteDocumentServer(collectionId, documentId, entityAlias); setIsDeleting(false); if (!res.success) { alert(res.error || "Hubo un error al eliminar el registro."); } }; return ( ); };