Fix navigating between steps on start from scratch flow
This commit is contained in:
@@ -213,12 +213,16 @@ export const UploadFlow = ({ state, onNext, onBack }: Props) => {
|
|||||||
return (
|
return (
|
||||||
<ValidationStepNew
|
<ValidationStepNew
|
||||||
initialData={state.data}
|
initialData={state.data}
|
||||||
file={uploadedFile!}
|
file={uploadedFile || new File([], "empty.xlsx")}
|
||||||
onBack={() => {
|
onBack={() => {
|
||||||
if (onBack) {
|
// If we started from scratch, we need to go back to the upload step
|
||||||
// When going back, preserve the global selections
|
if (state.isFromScratch) {
|
||||||
setPersistedGlobalSelections(state.globalSelections)
|
onNext({
|
||||||
onBack()
|
type: StepType.upload
|
||||||
|
});
|
||||||
|
} else if (onBack) {
|
||||||
|
// Use the provided onBack function
|
||||||
|
onBack();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onNext={(validatedData) => {
|
onNext={(validatedData) => {
|
||||||
@@ -226,7 +230,7 @@ export const UploadFlow = ({ state, onNext, onBack }: Props) => {
|
|||||||
onNext({
|
onNext({
|
||||||
type: StepType.imageUpload,
|
type: StepType.imageUpload,
|
||||||
data: validatedData,
|
data: validatedData,
|
||||||
file: uploadedFile!,
|
file: uploadedFile || new File([], "empty.xlsx"),
|
||||||
globalSelections: state.globalSelections
|
globalSelections: state.globalSelections
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
@@ -238,21 +242,13 @@ export const UploadFlow = ({ state, onNext, onBack }: Props) => {
|
|||||||
<ImageUploadStep
|
<ImageUploadStep
|
||||||
data={state.data}
|
data={state.data}
|
||||||
file={state.file}
|
file={state.file}
|
||||||
onBack={() => {
|
onBack={onBack}
|
||||||
if (onBack) {
|
|
||||||
onNext({
|
|
||||||
type: StepType.validateData,
|
|
||||||
data: state.data,
|
|
||||||
globalSelections: state.globalSelections
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
onSubmit={(data, file) => {
|
onSubmit={(data, file) => {
|
||||||
// Create a Result object from the array data
|
// Create a Result object from the array data
|
||||||
const result = {
|
const result = {
|
||||||
validData: data,
|
validData: data as Data<string>[],
|
||||||
invalidData: [],
|
invalidData: [] as Data<string>[],
|
||||||
all: data
|
all: data as Data<string>[]
|
||||||
};
|
};
|
||||||
onSubmit(result, file);
|
onSubmit(result, file);
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user