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