umami/src/app/(main)/websites/[websiteId]/settings/WebsiteDeleteForm.tsx
2025-11-22 22:42:42 -08:00

40 lines
977 B
TypeScript

import { TypeConfirmationForm } from '@/components/common/TypeConfirmationForm';
import { useDeleteQuery, useMessages } from '@/components/hooks';
const CONFIRM_VALUE = 'DELETE';
export function WebsiteDeleteForm({
websiteId,
onSave,
onClose,
}: {
websiteId: string;
onSave?: () => void;
onClose?: () => void;
}) {
const { formatMessage, labels } = useMessages();
const { mutateAsync, isPending, error, touch } = useDeleteQuery(`/websites/${websiteId}`);
const handleConfirm = async () => {
await mutateAsync(null, {
onSuccess: async () => {
touch('websites');
touch(`websites:${websiteId}`);
onSave?.();
onClose?.();
},
});
};
return (
<TypeConfirmationForm
confirmationValue={CONFIRM_VALUE}
onConfirm={handleConfirm}
onClose={onClose}
isLoading={isPending}
error={error}
buttonLabel={formatMessage(labels.delete)}
buttonVariant="danger"
/>
);
}