Skip to content

Commit

Permalink
refactor: rename outline_geojson & outline_no_fly_zones
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Aug 6, 2024
1 parent f531b81 commit 4eaa101
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default function DefineAOI({
drawProjectAreaEnable: false,
}),
);
setValue('outline_geojson', drawnProjectArea);
setValue('outline', drawnProjectArea);
if (resetDrawTool) {
resetDrawTool();
}
Expand Down Expand Up @@ -114,7 +114,7 @@ export default function DefineAOI({
drawNoFlyZoneEnable: false,
}),
);
setValue('outline_no_fly_zones', drawnNoFlyZone);
setValue('no_fly_zones', drawnNoFlyZone);
if (resetDrawTool) {
resetDrawTool();
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -232,15 +232,15 @@ export default function DefineAOI({
<FormControl className="naxatw-mt-2">
<Controller
control={control}
name="outline_geojson"
name="outline"
rules={{
required: 'Project Area is Required',
}}
render={({ field: { value } }) => {
// console.log(value, 'value12');
return (
<FileUpload
name="outline_geojson"
name="outline"
data={value}
onChange={handleProjectAreaFileChange}
fileAccept=".geojson, .kml"
Expand All @@ -252,7 +252,7 @@ export default function DefineAOI({
}}
/>
<ErrorMessage
message={errors?.outline_geojson?.message as string}
message={errors?.outline?.message as string}
/>
</FormControl>
</>
Expand Down Expand Up @@ -352,10 +352,10 @@ export default function DefineAOI({
<FormControl className="naxatw-mt-2">
<Controller
control={control}
name="outline_no_fly_zones"
name="no_fly_zones"
render={({ field: { value } }) => (
<FileUpload
name="outline_no_fly_zones"
name="no_fly_zones"
data={value}
onChange={handleNoFlyZoneFileChange}
isValid={validateAreaOfFileUpload}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default function MapSection() {
(acc, curr) => {
return {
...acc,
features: [...acc.features, curr.outline_geojson],
features: [...acc.features, curr.outline],
};
},
{
Expand Down Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/components/Projects/MapSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function ProjectsMapSection() {
(acc: Record<string, any>, current: Record<string, any>) => {
return {
...acc,
features: [...acc.features, centroid(current.outline_geojson)],
features: [...acc.features, centroid(current.outline)],
};
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/views/IndividualProject/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function IndividualProject() {
dispatch(
setProjectState({
tasksData: res.tasks,
projectArea: res.outline_geojson,
projectArea: res.outline,
}),
),
});
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/views/Projects/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
/>
),
)
Expand Down

0 comments on commit 4eaa101

Please sign in to comment.