Files
twenty_crm/packages/twenty-front/src/modules/settings/profile/components/DeleteAccount.tsx
martmull 9080981990 5509 remove flash on intermediate verify step when sign in with sso (#5526)
- remove flash on /verify
- remove flash on signInUp
- remove useless redirections and hooks
- Remove DefaultHomePage component
- Move redirections to /objects/companies in PageChangeEffect
- add useShowAuthModal hooks and tests
- add usePageChangeEffectNaviteLocation hooks and tests
- fix refresh token expired produces blank screen
2024-05-25 10:36:59 +02:00

57 lines
1.7 KiB
TypeScript

import { useState } from 'react';
import { useRecoilValue } from 'recoil';
import { H2Title } from 'twenty-ui';
import { useAuth } from '@/auth/hooks/useAuth';
import { currentUserState } from '@/auth/states/currentUserState';
import { Button } from '@/ui/input/button/components/Button';
import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal';
import { useDeleteUserAccountMutation } from '~/generated/graphql';
export const DeleteAccount = () => {
const [isDeleteAccountModalOpen, setIsDeleteAccountModalOpen] =
useState(false);
const [deleteUserAccount] = useDeleteUserAccountMutation();
const currentUser = useRecoilValue(currentUserState);
const userEmail = currentUser?.email;
const { signOut } = useAuth();
const deleteAccount = async () => {
await deleteUserAccount();
await signOut();
};
return (
<>
<H2Title
title="Danger zone"
description="Delete account and all the associated data"
/>
<Button
accent="danger"
onClick={() => setIsDeleteAccountModalOpen(true)}
variant="secondary"
title="Delete account"
/>
<ConfirmationModal
confirmationValue={userEmail}
confirmationPlaceholder={userEmail ?? ''}
isOpen={isDeleteAccountModalOpen}
setIsOpen={setIsDeleteAccountModalOpen}
title="Account Deletion"
subtitle={
<>
This action cannot be undone. This will permanently delete your
entire account. <br /> Please type in your email to confirm.
</>
}
onConfirmClick={deleteAccount}
deleteButtonText="Delete account"
/>
</>
);
};