56cada6335
* feat: wip import csv * feat: start implementing twenty UI * feat: new radio button component * feat: use new radio button component and fix scroll issue * fix: max height modal * feat: wip try to customize react-data-grid to match design * feat: wip match columns * feat: wip match column selection * feat: match column * feat: clean heading component & try to fix scroll in last step * feat: validation step * fix: small cleaning and remove unused component * feat: clean folder architecture * feat: remove translations * feat: remove chackra theme * feat: remove unused libraries * feat: use option button to open spreadsheet & fix stories * Fix lint and fix imports --------- Co-authored-by: Charles Bochet <charles@twenty.com>
68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import { useCallback, useState } from 'react';
|
|
import styled from '@emotion/styled';
|
|
|
|
import { Heading } from '@/spreadsheet-import/components/core/Heading';
|
|
import { Radio } from '@/ui/input/radio/components/Radio';
|
|
import { RadioGroup } from '@/ui/input/radio/components/RadioGroup';
|
|
import { Modal } from '@/ui/modal/components/Modal';
|
|
|
|
import { ContinueButton } from '../../core/ContinueButton';
|
|
|
|
const Content = styled(Modal.Content)`
|
|
align-items: center;
|
|
`;
|
|
|
|
const StyledHeading = styled(Heading)`
|
|
margin-bottom: ${({ theme }) => theme.spacing(8)};
|
|
`;
|
|
|
|
const RadioContainer = styled.div`
|
|
display: flex;
|
|
flex-direction: column;
|
|
flex-grow: 1;
|
|
height: 0px;
|
|
`;
|
|
|
|
type SelectSheetProps = {
|
|
sheetNames: string[];
|
|
onContinue: (sheetName: string) => Promise<void>;
|
|
};
|
|
|
|
export const SelectSheetStep = ({
|
|
sheetNames,
|
|
onContinue,
|
|
}: SelectSheetProps) => {
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
|
|
const [value, setValue] = useState(sheetNames[0]);
|
|
|
|
const handleOnContinue = useCallback(
|
|
async (data: typeof value) => {
|
|
setIsLoading(true);
|
|
await onContinue(data);
|
|
setIsLoading(false);
|
|
},
|
|
[onContinue],
|
|
);
|
|
|
|
return (
|
|
<>
|
|
<Content>
|
|
<StyledHeading title="Select the sheet to use" />
|
|
<RadioContainer>
|
|
<RadioGroup onValueChange={(value) => setValue(value)} value={value}>
|
|
{sheetNames.map((sheetName) => (
|
|
<Radio value={sheetName} key={sheetName} />
|
|
))}
|
|
</RadioGroup>
|
|
</RadioContainer>
|
|
</Content>
|
|
<ContinueButton
|
|
isLoading={isLoading}
|
|
onContinue={() => handleOnContinue(value)}
|
|
title="Next"
|
|
/>
|
|
</>
|
|
);
|
|
};
|