Skip to content

Commit

Permalink
fix(ui-map): add missing api error return
Browse files Browse the repository at this point in the history
  • Loading branch information
hdinia committed Feb 28, 2024
1 parent 6e8f61b commit 631956e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function CreateAreaDialog(props: Props) {
////////////////////////////////////////////////////////////////

const handleSubmit = (data: SubmitHandlerPlus<typeof defaultValues>) => {
createArea(data.values.name);
return createArea(data.values.name.trim());
};

////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,13 @@ function Map() {
////////////////////////////////////////////////////////////////

const handleCreateArea = async (name: string) => {
setOpenDialog(false);
try {
if (study) {
dispatch(createStudyMapNode({ studyId: study.id, name }));
return dispatch(createStudyMapNode({ studyId: study.id, name }))
.unwrap()
.then(() => {
setOpenDialog(false);
});
}
} catch (e) {
enqueueErrorSnackbar(t("study.error.createArea"), e as AxiosError);
Expand Down Expand Up @@ -206,6 +209,7 @@ function Map() {
/>
{openDialog && (
<CreateAreaDialog
studyId={study.id}
open={openDialog}
onClose={handleClose}
createArea={handleCreateArea}
Expand Down

0 comments on commit 631956e

Please sign in to comment.