mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
44 lines
978 B
TypeScript
44 lines
978 B
TypeScript
import { useApi, useMessages } from 'components/hooks';
|
|
import TypeConfirmationForm from 'components/common/TypeConfirmationForm';
|
|
|
|
const CONFIRM_VALUE = 'DELETE';
|
|
|
|
export function WebsiteDeleteForm({
|
|
websiteId,
|
|
onSave,
|
|
onClose,
|
|
}: {
|
|
websiteId: string;
|
|
onSave?: () => void;
|
|
onClose?: () => void;
|
|
}) {
|
|
const { formatMessage, labels } = useMessages();
|
|
const { del, useMutation } = useApi();
|
|
const { mutate, isPending, error } = useMutation({
|
|
mutationFn: () => del(`/websites/${websiteId}`),
|
|
});
|
|
|
|
const handleConfirm = async () => {
|
|
mutate(null, {
|
|
onSuccess: async () => {
|
|
onSave?.();
|
|
onClose?.();
|
|
},
|
|
});
|
|
};
|
|
|
|
return (
|
|
<TypeConfirmationForm
|
|
confirmationValue={CONFIRM_VALUE}
|
|
onConfirm={handleConfirm}
|
|
onClose={onClose}
|
|
isLoading={isPending}
|
|
error={error}
|
|
buttonLabel={formatMessage(labels.delete)}
|
|
buttonVariant="danger"
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default WebsiteDeleteForm;
|