2023-07-29 21:21:21 +02:00
|
|
|
import { Button, Group, Stack, Text } from '@mantine/core';
|
|
|
|
|
import { ContextModalProps, modals } from '@mantine/modals';
|
2023-08-06 14:12:39 +02:00
|
|
|
import { useTranslation } from 'next-i18next';
|
2023-07-29 21:21:21 +02:00
|
|
|
import { api } from '~/utils/api';
|
|
|
|
|
|
2023-08-06 14:12:39 +02:00
|
|
|
export const DeleteInviteModal = ({ id, innerProps }: ContextModalProps<{ tokenId: string }>) => {
|
|
|
|
|
const { t } = useTranslation('manage/users/invites');
|
|
|
|
|
const utils = api.useContext();
|
|
|
|
|
const { isLoading, mutateAsync: deleteAsync } = api.invites.delete.useMutation({
|
2023-07-29 21:21:21 +02:00
|
|
|
onSuccess: async () => {
|
2023-08-06 14:12:39 +02:00
|
|
|
await utils.invites.all.invalidate();
|
2023-07-29 21:21:21 +02:00
|
|
|
modals.close(id);
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
return (
|
|
|
|
|
<Stack>
|
2023-08-06 14:12:39 +02:00
|
|
|
<Text>{t('modals.delete.description')}</Text>
|
2023-07-29 21:21:21 +02:00
|
|
|
|
|
|
|
|
<Group grow>
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => {
|
|
|
|
|
modals.close(id);
|
|
|
|
|
}}
|
2023-07-31 21:40:37 +02:00
|
|
|
variant="light"
|
|
|
|
|
color="gray"
|
2023-07-29 21:21:21 +02:00
|
|
|
>
|
2023-08-06 14:12:39 +02:00
|
|
|
{t('common:cancel')}
|
2023-07-29 21:21:21 +02:00
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
onClick={async () => {
|
2023-08-06 14:12:39 +02:00
|
|
|
await deleteAsync({
|
2023-07-29 21:21:21 +02:00
|
|
|
tokenId: innerProps.tokenId,
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
disabled={isLoading}
|
2023-07-31 21:40:37 +02:00
|
|
|
variant="light"
|
|
|
|
|
color="red"
|
2023-07-29 21:21:21 +02:00
|
|
|
>
|
2023-08-06 14:12:39 +02:00
|
|
|
{t('common:delete')}
|
2023-07-29 21:21:21 +02:00
|
|
|
</Button>
|
|
|
|
|
</Group>
|
|
|
|
|
</Stack>
|
|
|
|
|
);
|
|
|
|
|
};
|