From 4eaa10109ce2f1d221d879fae527196590de20f2 Mon Sep 17 00:00:00 2001 From: spwoodcock Date: Wed, 7 Aug 2024 00:53:02 +0100 Subject: [PATCH] refactor: rename outline_geojson & outline_no_fly_zones --- .../CreateprojectLayout/index.tsx | 16 ++++++++-------- .../FormContents/DefineAOI/index.tsx | 18 +++++++++--------- .../IndividualProject/MapSection/index.tsx | 4 ++-- .../components/Projects/MapSection/index.tsx | 2 +- .../src/views/IndividualProject/index.tsx | 2 +- src/frontend/src/views/Projects/index.tsx | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/frontend/src/components/CreateProject/CreateprojectLayout/index.tsx b/src/frontend/src/components/CreateProject/CreateprojectLayout/index.tsx index 6f0c7062..a08b3787 100644 --- a/src/frontend/src/components/CreateProject/CreateprojectLayout/index.tsx +++ b/src/frontend/src/components/CreateProject/CreateprojectLayout/index.tsx @@ -78,8 +78,8 @@ export default function CreateprojectLayout() { name: '', short_description: '', description: '', - outline_geojson: null, - outline_no_fly_zones: null, + outline: null, + no_fly_zones: null, gsd_cm_px: null, dimension: null, is_terrain_follow: null, @@ -160,17 +160,17 @@ export default function CreateprojectLayout() { const onSubmit = (data: any) => { if (activeStep === 2) { if ( - !data?.outline_geojson || - (Array.isArray(data?.outline_geojson) && - data?.outline_geojson?.length === 0) + !data?.outline || + (Array.isArray(data?.outline) && + data?.outline?.length === 0) ) { toast.error('Please upload or draw and save project area'); return; } if ( isNoflyzonePresent === 'yes' && - (!data?.outline_no_fly_zones || - data?.outline_no_fly_zones?.length === 0) + (!data?.no_fly_zones || + data?.no_fly_zones?.length === 0) ) { toast.error('Please upload or draw and save No Fly zone area'); return; @@ -187,7 +187,7 @@ export default function CreateprojectLayout() { is_terrain_follow: isTerrainFollow === 'hilly', }; // remove key - if (isNoflyzonePresent === 'no') delete payload?.outline_no_fly_zones; + if (isNoflyzonePresent === 'no') delete payload?.no_fly_zones; createProject(payload); }; diff --git a/src/frontend/src/components/CreateProject/FormContents/DefineAOI/index.tsx b/src/frontend/src/components/CreateProject/FormContents/DefineAOI/index.tsx index 7e8498c7..949bf93c 100644 --- a/src/frontend/src/components/CreateProject/FormContents/DefineAOI/index.tsx +++ b/src/frontend/src/components/CreateProject/FormContents/DefineAOI/index.tsx @@ -82,7 +82,7 @@ export default function DefineAOI({ drawProjectAreaEnable: false, }), ); - setValue('outline_geojson', drawnProjectArea); + setValue('outline', drawnProjectArea); if (resetDrawTool) { resetDrawTool(); } @@ -114,7 +114,7 @@ export default function DefineAOI({ drawNoFlyZoneEnable: false, }), ); - setValue('outline_no_fly_zones', drawnNoFlyZone); + setValue('no_fly_zones', drawnNoFlyZone); if (resetDrawTool) { resetDrawTool(); } @@ -133,7 +133,7 @@ export default function DefineAOI({ if (typeof z === 'object' && !Array.isArray(z) && z !== null) { const convertedGeojson = flatten(z); dispatch(setCreateProjectState({ projectArea: convertedGeojson })); - setValue('outline_geojson', convertedGeojson); + setValue('outline', convertedGeojson); } }); } catch (err: any) { @@ -177,7 +177,7 @@ export default function DefineAOI({ if (typeof z === 'object' && !Array.isArray(z) && z !== null) { const convertedGeojson = flatten(z); dispatch(setCreateProjectState({ noFlyZone: convertedGeojson })); - setValue('outline_no_fly_zones', convertedGeojson); + setValue('no_fly_zones', convertedGeojson); } }); } catch (err: any) { @@ -232,7 +232,7 @@ export default function DefineAOI({ @@ -352,10 +352,10 @@ export default function DefineAOI({ ( { return { ...acc, - features: [...acc.features, curr.outline_geojson], + features: [...acc.features, curr.outline], }; }, { @@ -136,7 +136,7 @@ export default function MapSection() { map={map as Map} id={`tasks-layer-${task?.id}-${taskStatusObj?.[task?.id]}`} visibleOnMap={task?.id && taskStatusObj} - geojson={task.outline_geojson as GeojsonType} + geojson={task.outline as GeojsonType} interactions={['feature']} layerOptions={ taskStatusObj?.[`${task?.id}`] === 'LOCKED_FOR_MAPPING' diff --git a/src/frontend/src/components/Projects/MapSection/index.tsx b/src/frontend/src/components/Projects/MapSection/index.tsx index b8ddd07d..8b7fd410 100644 --- a/src/frontend/src/components/Projects/MapSection/index.tsx +++ b/src/frontend/src/components/Projects/MapSection/index.tsx @@ -22,7 +22,7 @@ export default function ProjectsMapSection() { (acc: Record, current: Record) => { return { ...acc, - features: [...acc.features, centroid(current.outline_geojson)], + features: [...acc.features, centroid(current.outline)], }; }, { diff --git a/src/frontend/src/views/IndividualProject/index.tsx b/src/frontend/src/views/IndividualProject/index.tsx index 2cbaf8ac..16d7b741 100644 --- a/src/frontend/src/views/IndividualProject/index.tsx +++ b/src/frontend/src/views/IndividualProject/index.tsx @@ -47,7 +47,7 @@ export default function IndividualProject() { dispatch( setProjectState({ tasksData: res.tasks, - projectArea: res.outline_geojson, + projectArea: res.outline, }), ), }); diff --git a/src/frontend/src/views/Projects/index.tsx b/src/frontend/src/views/Projects/index.tsx index 04266d1b..ba10a04d 100644 --- a/src/frontend/src/views/Projects/index.tsx +++ b/src/frontend/src/views/Projects/index.tsx @@ -51,7 +51,7 @@ export default function Projects() { containerId={`map-libre-map-${singleproject.id}`} title={singleproject.name} description={singleproject.description} - geojson={singleproject.outline_geojson} + geojson={singleproject.outline} /> ), )