mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 07:37:11 +01:00
41 lines
996 B
TypeScript
41 lines
996 B
TypeScript
import { AlertDialog, Row } from '@umami/react-zen';
|
|
import { useDeleteQuery, useMessages, useModified } from '@/components/hooks';
|
|
|
|
export function UserDeleteForm({
|
|
userId,
|
|
username,
|
|
onSave,
|
|
onClose,
|
|
}: {
|
|
userId: string;
|
|
username: string;
|
|
onSave?: () => void;
|
|
onClose?: () => void;
|
|
}) {
|
|
const { messages, labels, formatMessage } = useMessages();
|
|
const { mutateAsync } = useDeleteQuery(`/users/${userId}`);
|
|
const { touch } = useModified();
|
|
|
|
const handleConfirm = async () => {
|
|
await mutateAsync(null, {
|
|
onSuccess: async () => {
|
|
touch('users');
|
|
touch(`users:${userId}`);
|
|
onSave?.();
|
|
onClose?.();
|
|
},
|
|
});
|
|
};
|
|
|
|
return (
|
|
<AlertDialog
|
|
title={formatMessage(labels.delete)}
|
|
onConfirm={handleConfirm}
|
|
onCancel={onClose}
|
|
confirmLabel={formatMessage(labels.delete)}
|
|
isDanger
|
|
>
|
|
<Row gap="1">{formatMessage(messages.confirmDelete, { target: username })}</Row>
|
|
</AlertDialog>
|
|
);
|
|
}
|