✨ Add deletion for registration tokens
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
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);
|
||||
}}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
onClick={async () => {
|
||||
await mutateAsync({
|
||||
tokenId: innerProps.tokenId,
|
||||
});
|
||||
}}
|
||||
disabled={isLoading}
|
||||
>
|
||||
Delete
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
@@ -8,6 +8,7 @@ import { CategoryEditModal } from '~/components/Dashboard/Wrappers/Category/Cate
|
||||
|
||||
import { DeleteUserModal } from './delete-user/delete-user.modal';
|
||||
import { CreateRegistrationTokenModal } from './create-registration-token/create-registration-token.modal';
|
||||
import { DeleteRegistrationTokenModal } from './delete-registration-token/delete-registration-token.modal';
|
||||
|
||||
export const modals = {
|
||||
editApp: EditAppModal,
|
||||
@@ -18,7 +19,8 @@ export const modals = {
|
||||
changeAppPositionModal: ChangeAppPositionModal,
|
||||
changeIntegrationPositionModal: ChangeWidgetPositionModal,
|
||||
deleteUserModal: DeleteUserModal,
|
||||
createRegistrationTokenModal: CreateRegistrationTokenModal
|
||||
createRegistrationTokenModal: CreateRegistrationTokenModal,
|
||||
deleteRegistrationTokenModal: DeleteRegistrationTokenModal
|
||||
};
|
||||
|
||||
declare module '@mantine/modals' {
|
||||
|
||||
Reference in New Issue
Block a user