Files
twenty/packages/twenty-front/src/modules/settings/profile/components/DeleteAccount.tsx
Abdullah d1cbd709bd Extract typography components from twenty-front to twenty-ui. (#5466)
Removed the following components from twenty-front and moved them to
twenty-ui.
- H1Title.
- H2Title.
- H3Title.

Moving components in smaller chunks to ease the process of resolving
conflicts.

<img width="1255" alt="image"
src="https://github.com/twentyhq/twenty/assets/125115953/a3953659-5dfd-4d03-a6de-50b064129d55">

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-05-22 10:52:35 +02:00

57 lines
1.7 KiB
TypeScript

import { useState } from 'react';
import { useRecoilValue } from 'recoil';
import { H2Title } from 'twenty-ui';
import { useSignOutAndRedirect } from '@/auth/hooks/useSignOutAndRedirect';
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 handleLogout = useSignOutAndRedirect();
const deleteAccount = async () => {
await deleteUserAccount();
handleLogout();
};
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"
/>
</>
);
};