Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Create Project Issues #87

Merged
merged 23 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f545ad0
fix: hide the add projects button when signedInAs drone operator
Prajwalism Jul 19, 2024
3b916e4
fix: add asterisk to required fields
Prajwalism Jul 21, 2024
71892b0
Merge branch 'main' of github.com:hotosm/Drone-TM into fix/create-pro…
Prajwalism Jul 21, 2024
8d4bc33
feat: add modal to warn user of unsaved changes while exitting create…
Prajwalism Jul 21, 2024
7a45f2a
fix: change the label of dimension to km
Prajwalism Jul 21, 2024
4865204
feat: add refresh token to local storage
Prajwalism Jul 22, 2024
534f780
fix: change label to metre in generate task section
Prajwalism Jul 22, 2024
54ccc24
feat: add package mapbox-gl-draw-cutline-mode for drawing polygons
Prajwalism Jul 22, 2024
8266dbc
feat: add a util reverseLineString
Prajwalism Jul 22, 2024
19e35f7
feat: modify useDrawTool
Prajwalism Jul 22, 2024
91afd96
feat: enable draw project area in define AOI section
Prajwalism Jul 22, 2024
2474a93
hotfix, precommit prettier making unwanted changes to forntend code
mahesh-naxa Jul 22, 2024
91d8360
feat: add type to geojson
Prajwalism Jul 22, 2024
c3475d4
feat: add reducer to reset drawn areas to initial state
Prajwalism Jul 22, 2024
e93e15d
feat: close the modal when navigating to projects section
Prajwalism Jul 22, 2024
4d59564
feat: enable draw and reset project ares
Prajwalism Jul 24, 2024
13688db
refactor: change the variable name of projectArea
Prajwalism Jul 24, 2024
8839f64
Merge branch 'main' of github.com:hotosm/Drone-TM into fix/create-pro…
Prajwalism Jul 24, 2024
6310af6
fix: temporarily remove publish option in create project section
Prajwalism Jul 24, 2024
d4abdb9
fix: remove navbar until user fills the profile first
Prajwalism Jul 24, 2024
f3b0e87
feat: add 100km validation to drawn areas
Prajwalism Jul 24, 2024
414fe23
feat: add GFDRR logo to landing page
Prajwalism Jul 24, 2024
517dd43
refactor: modify the custom vector layer component to contain interac…
Prajwalism Jul 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"dependencies": {
"@mapbox/mapbox-gl-draw": "^1.4.2",
"@mapbox/mapbox-gl-draw-static-mode": "^1.0.1",
"mapbox-gl-draw-cut-line-mode": "^1.2.0",
"@radix-ui/react-popover": "^1.0.6",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-switch": "^1.0.3",
Expand Down
7 changes: 6 additions & 1 deletion src/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ export default function App() {
};

// add routes where you dont want navigation bar
const routesWithoutNavbar = ['/', '/login', '/forgot-password'];
const routesWithoutNavbar = [
'/',
'/login',
'/forgot-password',
'/user-profile',
];

return (
<>
Expand Down
Binary file added src/frontend/src/assets/images/GFDRR-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { useNavigate } from 'react-router-dom';
import { useTypedDispatch } from '@Store/hooks';
import { FlexRow } from '@Components/common/Layouts';
import Icon from '@Components/common/Icon';
import { toggleModal } from '@Store/actions/common';

export default function CreateProjectHeader() {
const navigate = useNavigate();
const dispatch = useTypedDispatch();
return (
<FlexRow className="naxatw-items-center">
<Icon name="west" onClick={() => navigate('/projects')} />
<Icon
name="west"
onClick={() => dispatch(toggleModal('quit-create-project'))}
/>
<h5 className="naxatw-ml-4 naxatw-font-bold">Project /</h5>
<span className="naxatw-text-body-lg">&nbsp;Add Project</span>
</FlexRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export default function CreateprojectLayout() {
};

return (
<section className="project-form-layout">
<section className="project-form-layout naxatw-bg-[#FAFAFA]">
<div className="naxatw-grid naxatw-grid-cols-4 naxatw-gap-5">
{/* description */}
<div className="description naxatw-col-span-1 naxatw-h-[32.625rem] naxatw-animate-fade-up naxatw-bg-white">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { useTypedDispatch } from '@Store/hooks';
import { useNavigate } from 'react-router-dom';
import { FlexRow } from '@Components/common/Layouts';
import { Button } from '@Components/RadixComponents/Button';
import { toggleModal } from '@Store/actions/common';

export default function ExitCreateProjectModal() {
const dispatch = useTypedDispatch();
const navigate = useNavigate();

return (
<section>
<p className="naxatw-mb-3">
This page has some unsaved changes, are you sure you want to leave this
page?
</p>
<FlexRow className="naxatw-w-full" gap={2}>
<Button
variant="ghost"
className="naxatw-text-red"
onClick={() => {
navigate('/projects');
dispatch(toggleModal(null));
}}
>
Leave
</Button>
<Button
className="naxatw-bg-red naxatw-px-5"
onClick={() => dispatch(toggleModal(null))}
>
Stay
</Button>
</FlexRow>
</section>
);
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { useTypedDispatch, useTypedSelector } from '@Store/hooks';
// import { useTypedDispatch, useTypedSelector } from '@Store/hooks';
import { FlexColumn } from '@Components/common/Layouts';
import { FormControl, Label, Input } from '@Components/common/FormUI';
import RadioButton from '@Components/common/RadioButton';
// import RadioButton from '@Components/common/RadioButton';
import ErrorMessage from '@Components/common/ErrorMessage';
import { UseFormPropsType } from '@Components/common/FormUI/types';
import { setCreateProjectState } from '@Store/actions/createproject';
import { contributionsOptions } from '@Constants/createProject';
// import { setCreateProjectState } from '@Store/actions/createproject';
// import { contributionsOptions } from '@Constants/createProject';

export default function Conditions({
formProps,
}: {
formProps: UseFormPropsType;
}) {
const dispatch = useTypedDispatch();
// const dispatch = useTypedDispatch();

const { register, errors } = formProps;

const contributionsOption = useTypedSelector(
state => state.createproject.contributionsOption,
);
// const contributionsOption = useTypedSelector(
// state => state.createproject.contributionsOption,
// );

return (
<FlexColumn gap={5} className="naxatw-px-10 naxatw-py-5">
<FormControl>
<Label>Instructions for Drone Operators</Label>
<Label required>Instructions for Drone Operators</Label>
<Input
placeholder="Enter Instructions for Drone Operators"
{...register('per_task_instructions', {
Expand All @@ -34,18 +34,19 @@ export default function Conditions({
message={errors?.per_task_instructions?.message as string}
/>
</FormControl>
<RadioButton
{/* <RadioButton
required
topic="Publish"
options={contributionsOptions}
direction="column"
onChangeData={val => {
dispatch(setCreateProjectState({ contributionsOption: val }));
}}
value={contributionsOption}
/>
/> */}
<FormControl className="naxatw-gap-1">
<div className="naxatw-w-full">
<Label>Deadline for Submission</Label>
<Label required>Deadline for Submission</Label>
<Input
placeholder="Deadline for Submission"
type="date"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable no-unused-vars */
import { useEffect } from 'react';
import { useTypedSelector } from '@Store/hooks';
import { useTypedSelector, useTypedDispatch } from '@Store/hooks';
import { useMapLibreGLMap } from '@Components/common/MapLibreComponents';
import BaseLayerSwitcher from '@Components/common/MapLibreComponents/BaseLayerSwitcher';
import MapContainer from '@Components/common/MapLibreComponents/MapContainer';
Expand All @@ -8,8 +9,17 @@ import { GeojsonType } from '@Components/common/MapLibreComponents/types';
import { LngLatBoundsLike, Map } from 'maplibre-gl';
import { FeatureCollection } from 'geojson';
import getBbox from '@turf/bbox';
import useDrawTool from '@Components/common/MapLibreComponents/useDrawTool';
import { drawStyles } from '@Constants/map';
import { setCreateProjectState } from '@Store/actions/createproject';

export default function MapSection({
onResetButtonClick,
}: {
onResetButtonClick: (reset: any) => void;
}) {
const dispatch = useTypedDispatch();

export default function MapSection() {
const { map, isMapLoaded } = useMapLibreGLMap({
mapOptions: {
zoom: 5,
Expand All @@ -19,18 +29,42 @@ export default function MapSection() {
disableRotation: true,
});

const uploadedProjectArea = useTypedSelector(
state => state.createproject.uploadedProjectArea,
const drawProjectAreaEnable = useTypedSelector(
state => state.createproject.drawProjectAreaEnable,
);
const drawNoFlyZoneEnable = useTypedSelector(
state => state.createproject.drawNoFlyZoneEnable,
);
const uploadedNoFlyZone = useTypedSelector(
state => state.createproject.uploadedNoFlyZone,

const handleDrawEnd = (geojson: GeojsonType | null) => {
if (drawProjectAreaEnable) {
dispatch(setCreateProjectState({ drawnProjectArea: geojson }));
}
dispatch(setCreateProjectState({ drawnNoFlyZone: geojson }));
};

const { resetDraw } = useDrawTool({
map,
enable: drawProjectAreaEnable || drawNoFlyZoneEnable,
drawMode: 'draw_polygon',
styles: drawStyles,
onDrawEnd: handleDrawEnd,
});

useEffect(() => {
onResetButtonClick(resetDraw);
}, [onResetButtonClick, resetDraw]);

const projectArea = useTypedSelector(
state => state.createproject.projectArea,
);
const noFlyZone = useTypedSelector(state => state.createproject.noFlyZone);

useEffect(() => {
if (!uploadedProjectArea) return;
const bbox = getBbox(uploadedProjectArea as FeatureCollection);
if (!projectArea) return;
const bbox = getBbox(projectArea as FeatureCollection);
map?.fitBounds(bbox as LngLatBoundsLike, { padding: 25 });
}, [map, uploadedProjectArea]);
}, [map, projectArea]);

return (
<MapContainer
Expand All @@ -45,8 +79,8 @@ export default function MapSection() {
map={map as Map}
isMapLoaded={isMapLoaded}
id="uploaded-project-area"
geojson={uploadedProjectArea as GeojsonType}
visibleOnMap={!!uploadedProjectArea}
geojson={projectArea as GeojsonType}
visibleOnMap={!!projectArea}
layerOptions={{
type: 'fill',
paint: {
Expand All @@ -60,8 +94,8 @@ export default function MapSection() {
map={map as Map}
isMapLoaded={isMapLoaded}
id="uploaded-no-fly-zone"
geojson={uploadedNoFlyZone as GeojsonType}
visibleOnMap={!!uploadedNoFlyZone}
geojson={noFlyZone as GeojsonType}
visibleOnMap={!!noFlyZone}
layerOptions={{
type: 'fill',
paint: {
Expand Down
Loading
Loading