diff --git a/src/frontend/src/api/CreateProjectService.ts b/src/frontend/src/api/CreateProjectService.ts index ff0581e30c..3ed5703a1f 100755 --- a/src/frontend/src/api/CreateProjectService.ts +++ b/src/frontend/src/api/CreateProjectService.ts @@ -16,6 +16,7 @@ const CreateProjectService: Function = ( formUpload: any, dataExtractFile: any, lineExtractFile: any, + basemapSelection: string, ) => { return async (dispatch) => { dispatch(CreateProjectActions.CreateProjectLoading(true)); @@ -73,6 +74,14 @@ const CreateProjectService: Function = ( dataExtractFile, ), ); + if (basemapSelection !== '') { + await dispatch( + GenerateBasemapsService( + `${import.meta.env.VITE_API_URL}/tiles/${resp.id}/init?source=${basemapSelection}`, + payload, + ), + ); + } dispatch(CommonActions.SetLoading(false)); dispatch(CreateProjectActions.CreateProjectLoading(true)); @@ -201,6 +210,26 @@ const GenerateProjectQRService: Function = (url: string, payload: any, formUploa await postUploadArea(url, payload, formUpload); }; }; +const GenerateBasemapsService: Function = (url: string, payload: any) => { + return async (dispatch) => { + const triggerBasemapDownloads = async (url, payload) => { + try { + await axios.post(url); + } catch (error: any) { + dispatch( + CommonActions.SetSnackBar({ + open: true, + message: JSON.stringify(error?.response?.data?.detail), + variant: 'error', + duration: 2000, + }), + ); + } + }; + + await triggerBasemapDownloads(url, payload); + }; +}; const OrganisationService: Function = (url: string) => { return async (dispatch) => { @@ -524,6 +553,7 @@ export { CreateProjectService, FormCategoryService, GenerateProjectQRService, + GenerateBasemapsService, OrganisationService, UploadCustomXLSFormService, GenerateProjectLog, diff --git a/src/frontend/src/components/createnewproject/SplitTasks.tsx b/src/frontend/src/components/createnewproject/SplitTasks.tsx index 55e92b5ff6..cbe8d69d8a 100644 --- a/src/frontend/src/components/createnewproject/SplitTasks.tsx +++ b/src/frontend/src/components/createnewproject/SplitTasks.tsx @@ -62,6 +62,7 @@ const SplitTasks = ({ flag, geojsonFile, setGeojsonFile, customLineUpload, custo ); const isTasksGenerated = CoreModules.useAppSelector((state) => state.createproject.isTasksGenerated); const isFgbFetching = CoreModules.useAppSelector((state) => state.createproject.isFgbFetching); + const basemapSelection = CoreModules.useAppSelector((state) => state.createproject.basemapSelection); const toggleStep = (step, url) => { dispatch(CommonActions.SetCurrentStepFormStep({ flag: flag, step: step })); @@ -139,6 +140,7 @@ const SplitTasks = ({ flag, geojsonFile, setGeojsonFile, customLineUpload, custo customFormFile, customPolygonUpload, customLineUpload, + basemapSelection, ), ); dispatch(CreateProjectActions.SetIndividualProjectDetailsData({ ...projectDetails, ...formValues })); diff --git a/src/frontend/src/components/createnewproject/UploadArea.tsx b/src/frontend/src/components/createnewproject/UploadArea.tsx index 2bcba1ce65..56b9b9bfd8 100644 --- a/src/frontend/src/components/createnewproject/UploadArea.tsx +++ b/src/frontend/src/components/createnewproject/UploadArea.tsx @@ -42,6 +42,7 @@ const UploadArea = ({ flag, geojsonFile, setGeojsonFile, setCustomLineUpload, se const uploadAreaSelection = useAppSelector((state) => state.createproject.uploadAreaSelection); const drawToggle = useAppSelector((state) => state.createproject.drawToggle); const totalAreaSelection = useAppSelector((state) => state.createproject.totalAreaSelection); + const basemapSelection = useAppSelector((state) => state.createproject.basemapSelection); const submission = () => { dispatch(CreateProjectActions.SetIndividualProjectDetailsData(formValues)); @@ -205,40 +206,24 @@ const UploadArea = ({ flag, geojsonFile, setGeojsonFile, setCustomLineUpload, se btnText="Upload a Geojson" errorMsg={errors.uploadedAreaFile} /> - //
{geojsonFile?.name}
- //- // *The supported file formats are zipped shapefile, geojson or kml files. - //
- //- // Total Area: 234 sq.km - //
- //+ Optional: generate basemaps for tasks +
+ +