Fixed: In CSV import now users are able to come back to the previous step. (#5625)

Users now can make a back transition from the current step state.

- Added a `BackButton` component to `spreadsheet-import` in order to use
it within the step state components.
- Used the prebuilt `prevStep` from `useStepBar` and passed it as a prop
to the `Uploadflow` to get the previous state as activestep.
- Added a `previousState` to set the previous state with the required
key data.
- Added a `handleOnBack` function in `Uploadflow` to set the correct
state and call the `prevStep` function to make the transition.
- Added a callback function `onBack` and passed it as props to each step
state component.

fixes: #5564 



https://github.com/twentyhq/twenty/assets/140178357/be7e1a0a-0fb8-41f2-a207-dfc3208ca6f0

---------

Co-authored-by: Thomas Trompette <thomas.trompette@sfr.fr>
This commit is contained in:
Shashank Vishwakarma
2024-05-30 22:13:56 +05:30
committed by GitHub
parent a12c1aad5e
commit c7f2150ac7
11 changed files with 60 additions and 21 deletions
@@ -1,8 +1,8 @@
import { useCallback, useState } from 'react';
import styled from '@emotion/styled';
import { ContinueButton } from '@/spreadsheet-import/components/ContinueButton';
import { Heading } from '@/spreadsheet-import/components/Heading';
import { StepNavigationButton } from '@/spreadsheet-import/components/StepNavigationButton';
import { Radio } from '@/ui/input/components/Radio';
import { RadioGroup } from '@/ui/input/components/RadioGroup';
import { Modal } from '@/ui/layout/modal/components/Modal';
@@ -27,11 +27,13 @@ const StyledRadioContainer = styled.div`
type SelectSheetStepProps = {
sheetNames: string[];
onContinue: (sheetName: string) => Promise<void>;
onBack: () => void;
};
export const SelectSheetStep = ({
sheetNames,
onContinue,
onBack,
}: SelectSheetStepProps) => {
const [isLoading, setIsLoading] = useState(false);
@@ -58,11 +60,12 @@ export const SelectSheetStep = ({
</RadioGroup>
</StyledRadioContainer>
</StyledContent>
<ContinueButton
<StepNavigationButton
onClick={() => handleOnContinue(value)}
isLoading={isLoading}
onContinue={() => handleOnContinue(value)}
title="Next"
/>
<StepNavigationButton onClick={onBack} title="Back" />
</>
);
};