Files
twenty/packages/twenty-front/src/modules/spreadsheet-import/components/ModalCloseButton.tsx
T
Lucas Bordeau bf704bd1bc Improve CSV import sub-field selection (#11601)
This PR adds a better UX for selecting sub-fields when importing CSV
files.

Before : 

<img width="395" alt="image"
src="https://github.com/user-attachments/assets/5a599e7d-ed07-4531-8306-9d70e7cfa37d"
/>

After : 

<img width="298" alt="image"
src="https://github.com/user-attachments/assets/2be8a1df-d089-4341-970e-6db2b269141e"
/>

<img width="296" alt="image"
src="https://github.com/user-attachments/assets/584285f4-4e71-4abd-9adf-11819cab0dc5"
/>

- A util `getSubFieldOptionKey` has been made to be able to reference
the sub field in the `options` object of the spreadsheet import.
- New components have been created :
`MatchColumnSelectFieldSelectDropdownContent`,
`MatchColumnSelectSubFieldSelectDropdownContent` and
`MatchColumnSelectV2`
- Extracted the hard-coded option do not import into a constant
`DO_NOT_IMPORT_OPTION_KEY`
- Passed `availableFieldMetadataItems` to spreadsheet global options so
it's available anywhere in the hierarchy of components.

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
Co-authored-by: Charles Bochet <charlesBochet@users.noreply.github.com>
2025-04-16 15:08:24 +02:00

67 lines
1.7 KiB
TypeScript

import styled from '@emotion/styled';
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';
import { useLingui } from '@lingui/react/macro';
import { IconX } from 'twenty-ui/display';
import { IconButton } from 'twenty-ui/input';
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 { t } = useLingui();
const handleClose = () => {
if (activeStep === -1) {
onClose();
return;
}
enqueueDialog({
title: t`Exit import flow`,
message: t`Are you sure? Your current information will not be saved.`,
buttons: [
{ title: t`Cancel` },
{
title: t`Exit`,
onClick: onClose,
accent: 'danger',
role: 'confirm',
},
],
});
};
return (
<StyledCloseButtonContainer>
<IconButton Icon={IconX} onClick={handleClose} />
</StyledCloseButtonContainer>
);
};