Files
twenty/packages/twenty-front/src/modules/spreadsheet-import/components/ModalCloseButton.tsx
T
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

58 lines
1.5 KiB
TypeScript

import styled from '@emotion/styled';
import { IconButton, IconX } from 'twenty-ui';
import { useSpreadsheetImportInitialStep } from '@/spreadsheet-import/hooks/useSpreadsheetImportInitialStep';
import { useSpreadsheetImportInternal } from '@/spreadsheet-import/hooks/useSpreadsheetImportInternal';
import { useDialogManager } from '@/ui/feedback/dialog-manager/hooks/useDialogManager';
import { useStepBar } from '@/ui/navigation/step-bar/hooks/useStepBar';
const StyledCloseButtonContainer = styled.div`
align-items: center;
aspect-ratio: 1;
display: flex;
height: 60px;
justify-content: center;
position: absolute;
right: 0;
top: 0;
`;
type ModalCloseButtonProps = {
onClose: () => void;
};
export const ModalCloseButton = ({ onClose }: ModalCloseButtonProps) => {
const { initialStepState } = useSpreadsheetImportInternal();
const { initialStep } = useSpreadsheetImportInitialStep(
initialStepState?.type,
);
const { activeStep } = useStepBar({
initialStep,
});
const { enqueueDialog } = useDialogManager();
const handleClose = () => {
if (activeStep === -1) {
onClose();
return;
}
enqueueDialog({
title: 'Exit import flow',
message: 'Are you sure? Your current information will not be saved.',
buttons: [
{ title: 'Cancel' },
{ title: 'Exit', onClick: onClose, accent: 'danger', role: 'confirm' },
],
});
};
return (
<StyledCloseButtonContainer>
<IconButton Icon={IconX} onClick={handleClose} />
</StyledCloseButtonContainer>
);
};