Files
twenty/front/src/modules/spreadsheet-import/components/ModalCloseButton.tsx
T
Jérémy M c0cb3a47f3 Fix/csv import (#1397)
* feat: add ability to enable or disable header selection

* feat: limit to max of 200 records for now

* fix: bigger modal

* feat: add missing standard fields for company

* fix: person fields

* feat: add hotkeys on dialog

* feat: mobile device

* fix: company import error

* fix: csv import crash

* fix: use scoped hotkey
2023-09-04 11:50:12 +02:00

59 lines
1.5 KiB
TypeScript

import styled from '@emotion/styled';
import { useSpreadsheetImportInitialStep } from '@/spreadsheet-import/hooks/useSpreadsheetImportInitialStep';
import { useSpreadsheetImportInternal } from '@/spreadsheet-import/hooks/useSpreadsheetImportInternal';
import { IconButton } from '@/ui/button/components/IconButton';
import { useDialog } from '@/ui/dialog/hooks/useDialog';
import { IconX } from '@/ui/icon/index';
import { useStepBar } from '@/ui/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 } = useDialog();
function 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>
);
};