2023-07-29 21:21:21 +02:00
|
|
|
import { Button, Group, Stack, Text } from '@mantine/core';
|
|
|
|
|
import { ContextModalProps, modals } from '@mantine/modals';
|
|
|
|
|
import { api } from '~/utils/api';
|
|
|
|
|
|
|
|
|
|
export const DeleteRegistrationTokenModal = ({
|
|
|
|
|
context,
|
|
|
|
|
id,
|
|
|
|
|
innerProps,
|
|
|
|
|
}: ContextModalProps<{ tokenId: string }>) => {
|
|
|
|
|
const apiContext = api.useContext();
|
|
|
|
|
const { isLoading, mutateAsync } = api.registrationTokens.deleteRegistrationToken.useMutation({
|
|
|
|
|
onSuccess: async () => {
|
|
|
|
|
await apiContext.registrationTokens.getAllInvites.invalidate();
|
|
|
|
|
modals.close(id);
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
return (
|
|
|
|
|
<Stack>
|
|
|
|
|
<Text>
|
|
|
|
|
Are you sure, that you want to delete this invitation? Users with this link will no longer
|
|
|
|
|
be able to register using that link.
|
|
|
|
|
</Text>
|
|
|
|
|
|
|
|
|
|
<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
|
|
|
>
|
|
|
|
|
Cancel
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
onClick={async () => {
|
|
|
|
|
await mutateAsync({
|
|
|
|
|
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
|
|
|
>
|
|
|
|
|
Delete
|
|
|
|
|
</Button>
|
|
|
|
|
</Group>
|
|
|
|
|
</Stack>
|
|
|
|
|
);
|
|
|
|
|
};
|