Skip to content

Commit

Permalink
fix(frontend): allow 5-second delay after project creation (backend c…
Browse files Browse the repository at this point in the history
…atchup)
  • Loading branch information
spwoodcock committed Jun 7, 2024
1 parent 9605473 commit 4ebf975
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions src/frontend/src/components/createnewproject/SplitTasks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,23 +192,34 @@ const SplitTasks = ({ flag, geojsonFile, setGeojsonFile, customDataExtractUpload
);
}
};

useEffect(() => {
if (generateQrSuccess) {
const projectId = projectDetailsResponse?.id;
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'QR Generation Completed.',
variant: 'success',
duration: 2000,
}),
);
dispatch(CreateProjectActions.SetGenerateProjectQRSuccess(null));
navigate(`/project/${projectId}`);
dispatch(CreateProjectActions.ClearCreateProjectFormData());
dispatch(CreateProjectActions.SetCanSwitchCreateProjectSteps(false));
}
}, [generateQrSuccess]);
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));

const handleQRGeneration = async () => {
if (generateQrSuccess) {
const projectId = projectDetailsResponse?.id;
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'QR Generation Completed. Redirecting...',
variant: 'success',
duration: 2000,
}),
);

// Add 5-second delay to allow backend Entity generation to catch up
await delay(5000);

dispatch(CreateProjectActions.SetGenerateProjectQRSuccess(null));
navigate(`/project/${projectId}`);
dispatch(CreateProjectActions.ClearCreateProjectFormData());
dispatch(CreateProjectActions.SetCanSwitchCreateProjectSteps(false));
}
};

handleQRGeneration();
}, [generateQrSuccess]);

const renderTraceback = (errorText: string) => {
if (!errorText) {
Expand Down

0 comments on commit 4ebf975

Please sign in to comment.