Files
twenty/packages/twenty-front/src/modules/settings/profile/components/DeleteWorkspace.tsx
gitstart-app[bot] 0a28c15747 Migrate to twenty-ui - input/button (#7994)
This PR was created by [GitStart](https://gitstart.com/) to address the
requirements from this ticket:
[TWNTY-7529](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-7529).

 --- 

### Description

- Migrated all button components to `twenty-ui`    \
  \
  `Button`\
  `ButtonGroup`\
  `ColorPickerButton`\
  `FloatingButton`\
  `FloatingButtonGroup`\
  `FloatingIconButton`\
  `FloatingIconButtonGroup`\
  `IconButton`\
  `IconButtonGroup`\
  `LightButton`\
  `LightIconButton`\
  `LightIconButtonGroup`\
  `MainButton`\
  \
  Fixes twentyhq/private-issues#89

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2024-10-24 13:20:02 +02:00

53 lines
1.6 KiB
TypeScript

import { useState } from 'react';
import { useRecoilValue } from 'recoil';
import { Button, H2Title, IconTrash } from 'twenty-ui';
import { useAuth } from '@/auth/hooks/useAuth';
import { currentUserState } from '@/auth/states/currentUserState';
import { ConfirmationModal } from '@/ui/layout/modal/components/ConfirmationModal';
import { useDeleteCurrentWorkspaceMutation } from '~/generated/graphql';
export const DeleteWorkspace = () => {
const [isDeleteWorkSpaceModalOpen, setIsDeleteWorkSpaceModalOpen] =
useState(false);
const [deleteCurrentWorkspace] = useDeleteCurrentWorkspaceMutation();
const currentUser = useRecoilValue(currentUserState);
const userEmail = currentUser?.email;
const { signOut } = useAuth();
const deleteWorkspace = async () => {
await deleteCurrentWorkspace();
await signOut();
};
return (
<>
<H2Title title="Danger zone" description="Delete your whole workspace" />
<Button
accent="danger"
variant="secondary"
title="Delete workspace"
Icon={IconTrash}
onClick={() => setIsDeleteWorkSpaceModalOpen(true)}
/>
<ConfirmationModal
confirmationPlaceholder={userEmail}
confirmationValue={userEmail}
isOpen={isDeleteWorkSpaceModalOpen}
setIsOpen={setIsDeleteWorkSpaceModalOpen}
title="Workspace Deletion"
subtitle={
<>
This action cannot be undone. This will permanently delete your
entire workspace. <br /> Please type in your email to confirm.
</>
}
onConfirmClick={deleteWorkspace}
deleteButtonText="Delete workspace"
/>
</>
);
};