mirror of
https://github.com/umami-software/umami.git
synced 2026-02-16 02:25:35 +01:00
39 lines
953 B
TypeScript
39 lines
953 B
TypeScript
import { TypeConfirmationForm } from '@/components/common/TypeConfirmationForm';
|
|
import { useDeleteQuery, useMessages } from '@/components/hooks';
|
|
|
|
const CONFIRM_VALUE = 'DELETE';
|
|
|
|
export function TeamDeleteForm({
|
|
teamId,
|
|
onSave,
|
|
onClose,
|
|
}: {
|
|
teamId: string;
|
|
onSave?: () => void;
|
|
onClose?: () => void;
|
|
}) {
|
|
const { labels, formatMessage, getErrorMessage } = useMessages();
|
|
const { mutateAsync, error, isPending, touch } = useDeleteQuery(`/teams/${teamId}`);
|
|
|
|
const handleConfirm = async () => {
|
|
await mutateAsync(null, {
|
|
onSuccess: async () => {
|
|
touch('teams');
|
|
onSave?.();
|
|
onClose?.();
|
|
},
|
|
});
|
|
};
|
|
|
|
return (
|
|
<TypeConfirmationForm
|
|
confirmationValue={CONFIRM_VALUE}
|
|
onConfirm={handleConfirm}
|
|
onClose={onClose}
|
|
isLoading={isPending}
|
|
error={getErrorMessage(error)}
|
|
buttonLabel={formatMessage(labels.delete)}
|
|
buttonVariant="danger"
|
|
/>
|
|
);
|
|
}
|