mirror of
https://github.com/umami-software/umami.git
synced 2026-02-17 02:55:38 +01:00
43 lines
1 KiB
TypeScript
43 lines
1 KiB
TypeScript
import { useDeleteQuery, useMessages, useModified } from '@/components/hooks';
|
|
import { ConfirmationForm } from '@/components/common/ConfirmationForm';
|
|
|
|
export function TeamLeaveForm({
|
|
teamId,
|
|
userId,
|
|
teamName,
|
|
onSave,
|
|
onClose,
|
|
}: {
|
|
teamId: string;
|
|
userId: string;
|
|
teamName: string;
|
|
onSave: () => void;
|
|
onClose: () => void;
|
|
}) {
|
|
const { formatMessage, labels, messages, getErrorMessage } = useMessages();
|
|
const { mutateAsync, error, isPending } = useDeleteQuery(`/teams/${teamId}/users/${userId}`);
|
|
const { touch } = useModified();
|
|
|
|
const handleConfirm = async () => {
|
|
await mutateAsync(null, {
|
|
onSuccess: async () => {
|
|
touch('teams:members');
|
|
onSave();
|
|
onClose();
|
|
},
|
|
});
|
|
};
|
|
|
|
return (
|
|
<ConfirmationForm
|
|
buttonLabel={formatMessage(labels.leave)}
|
|
message={formatMessage(messages.confirmLeave, {
|
|
target: teamName,
|
|
})}
|
|
onConfirm={handleConfirm}
|
|
onClose={onClose}
|
|
isLoading={isPending}
|
|
error={getErrorMessage(error)}
|
|
/>
|
|
);
|
|
}
|