diff --git a/src/frontend/src/api/CreateProjectService.ts b/src/frontend/src/api/CreateProjectService.ts index 3a8d302de9..89160ab1aa 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) => { @@ -516,6 +545,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 22234d128d..cc2b02f820 100644 --- a/src/frontend/src/components/createnewproject/SplitTasks.tsx +++ b/src/frontend/src/components/createnewproject/SplitTasks.tsx @@ -61,6 +61,7 @@ const SplitTasks = ({ flag, geojsonFile, setGeojsonFile, customLineUpload, custo (state) => state.createproject.taskSplittingGeojsonLoading, ); const isTasksGenerated = CoreModules.useAppSelector((state) => state.createproject.isTasksGenerated); + 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 01f3c93281..8f925e28cd 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 }) => { 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 }) => { btnText="Upload a Geojson" errorMsg={errors.uploadedAreaFile} /> - //
- //
- // - //
- // resetFile()} /> - //
- //
- // {geojsonFile && ( - //
- //

{geojsonFile?.name}

- //
- // )} - //

- // *The supported file formats are zipped shapefile, geojson or kml files. - //

- //

- // Total Area: 234 sq.km - //

- //
)} +
+

+ Optional: generate basemaps for tasks +

+ +