Skip to content

Commit

Permalink
Merge branch 'development' of github.com:hotosm/fmtm into fix-invalid…
Browse files Browse the repository at this point in the history
…-geojson
  • Loading branch information
NSUWAL123 committed Jan 18, 2024
2 parents c63f654 + da99c41 commit 005bf17
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
42 changes: 41 additions & 1 deletion src/frontend/src/components/createnewproject/UploadArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ const UploadArea = ({ flag, geojsonFile, setGeojsonFile, setCustomLineUpload, se
const totalAreaSelection = useAppSelector((state) => state.createproject.totalAreaSelection);

const submission = () => {
if (totalAreaSelection) {
const totalArea = parseFloat(totalAreaSelection?.split(' ')[0]);
if (totalArea > 1000) {
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'Cannot create project of project area exceeding 1000 Sq.KM.',
variant: 'error',
duration: 3000,
}),
);
return;
}
}
dispatch(CreateProjectActions.SetIndividualProjectDetailsData(formValues));
dispatch(CommonActions.SetCurrentStepFormStep({ flag: flag, step: 3 }));
navigate('/select-form');
Expand Down Expand Up @@ -135,6 +149,32 @@ const UploadArea = ({ flag, geojsonFile, setGeojsonFile, setCustomLineUpload, se
dispatch(CreateProjectActions.SetTotalAreaSelection(null));
};

useEffect(() => {
if (totalAreaSelection) {
const totalArea = parseFloat(totalAreaSelection?.split(' ')[0]);
if (totalArea > 100) {
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'The project area exceeded over 100 Sq.KM.',
variant: 'warning',
duration: 3000,
}),
);
}
if (totalArea > 1000) {
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'The project area exceeded 1000 Sq.KM. and must be less than 1000 Sq.KM.',
variant: 'error',
duration: 3000,
}),
);
}
}
}, [totalAreaSelection]);

return (
<div className="fmtm-flex fmtm-gap-7 fmtm-flex-col lg:fmtm-flex-row">
<div className="fmtm-bg-white lg:fmtm-w-[20%] xl:fmtm-w-[17%] fmtm-px-5 fmtm-py-6">
Expand Down Expand Up @@ -266,7 +306,7 @@ const UploadArea = ({ flag, geojsonFile, setGeojsonFile, setCustomLineUpload, se
handleCustomChange('drawnGeojson', geojson);
dispatch(CreateProjectActions.SetDrawnGeojson(JSON.parse(geojson)));
dispatch(CreateProjectActions.SetTotalAreaSelection(area));
dispatch(CreateProjectActions.ClearProjectStepState());
dispatch(CreateProjectActions.ClearProjectStepState(formValues));
setCustomLineUpload(null);
setCustomPolygonUpload(null);
setGeojsonFile(null);
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/store/slices/CreateProjectSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,11 @@ const CreateProject = createSlice({
SetFgbFetchingStatus(state, action) {
state.isFgbFetching = action.payload;
},
ClearProjectStepState(state) {
ClearProjectStepState(state, action) {
state.dividedTaskGeojson = null;
state.splitTasksSelection = null;
state.dataExtractGeojson = null;
state.projectDetails = { ...state.projectDetails, customLineUpload: null, customPolygonUpload: null };
state.projectDetails = { ...action.payload, customLineUpload: null, customPolygonUpload: null };
},
},
});
Expand Down

0 comments on commit 005bf17

Please sign in to comment.