import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "../../ui/dialog.js"; import { useState } from "react"; import { Button, ButtonProps } from "../../ui/button.js"; import { useResourceDelete } from "../../../hooks/resources.js"; import { useRecord } from "../../../providers/record.js"; import { useResource } from "../../../providers/resource.js"; export const DeleteButton = ({ children, ...props }: ButtonProps) => { const [open, setOpen] = useState(false); const { record } = useRecord(); const { resource } = useResource(); const { mutate } = useResourceDelete(); async function handleDelete() { setOpen(false); await mutate({ id: record[resource.idKey] }); } return ( Are you sure? This action cannot be undone. This will permanently delete the record and remove it from the database. ); };