mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 07:37:11 +01:00
32 lines
943 B
TypeScript
32 lines
943 B
TypeScript
import { useApi, useMessages, useModified } from '@/components/hooks';
|
|
import ConfirmationForm from '@/components/common/ConfirmationForm';
|
|
|
|
export function UserDeleteForm({ userId, username, onSave, onClose }) {
|
|
const { messages, labels, formatMessage } = useMessages();
|
|
const { del, useMutation } = useApi();
|
|
const { mutate, error, isPending } = useMutation({ mutationFn: () => del(`/users/${userId}`) });
|
|
const { touch } = useModified();
|
|
|
|
const handleConfirm = async () => {
|
|
mutate(null, {
|
|
onSuccess: async () => {
|
|
touch('users');
|
|
onSave?.();
|
|
onClose?.();
|
|
},
|
|
});
|
|
};
|
|
|
|
return (
|
|
<ConfirmationForm
|
|
message={formatMessage(messages.confirmDelete, { target: <b>{username}</b> })}
|
|
onConfirm={handleConfirm}
|
|
onClose={onClose}
|
|
buttonLabel={formatMessage(labels.delete)}
|
|
isLoading={isPending}
|
|
error={error}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default UserDeleteForm;
|