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

Feat/drone operator image upload UI #374

Merged
merged 9 commits into from
Dec 2, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,39 @@ const MapSection = ({
);
const noFlyZone = useTypedSelector(state => state.createproject.noFlyZone);

function filterDuplicateFeature(
featuresData: any[],
geojsonFeatureObject: Record<string, any>,
) {
if (!geojsonFeatureObject) return [];
if (!featuresData) return [geojsonFeatureObject];
return featuresData.filter(
feature => feature.id !== geojsonFeatureObject.id,
);
}

const handleDrawEnd = (geojson: GeojsonType | null) => {
if (!geojson) return;
if (drawProjectAreaEnable) {
dispatch(setCreateProjectState({ drawnProjectArea: geojson }));
} else {
// @ts-ignore
let combindFeatures = geojson?.features;
// @ts-ignore
if (drawnNoFlyZone?.features) {
combindFeatures = filterDuplicateFeature(
// @ts-ignore
drawnNoFlyZone?.features,
// @ts-ignore
geojson?.features[0],
);
}
const collectiveGeojson: any = drawnNoFlyZone
? {
// @ts-ignore
...drawnNoFlyZone,
features: [
// @ts-ignore
...(drawnNoFlyZone?.features || []),
...(combindFeatures || []),
// @ts-ignore
...(geojson?.features || []),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ const DefineAOI = ({ formProps }: { formProps: UseFormPropsType }) => {
data={value}
onChange={handleProjectAreaFileChange}
fileAccept=".geojson, .kml"
placeholder="Upload project area (zipped shapefile, geojson or kml files)"
placeholder="Upload project area (zipped geojson files)"
isValid={validateAreaOfFileUpload}
{...formProps}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const QuestionBox = ({
variant="ghost"
className="naxatw-w-fit naxatw-bg-[#D73F3F] naxatw-text-[#FFFFFF]"
onClick={() => handleSubmit()}
disabled={flyable === 'no' && comment.length < 6}
disabled={flyable === 'yes'}
isLoading={commentIsUpdating}
>
Save
Expand Down
51 changes: 34 additions & 17 deletions src/frontend/src/components/DroneOperatorTask/MapSection/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable react/no-array-index-key */
import { useGetTaskWaypointQuery } from '@Api/tasks';
import { useGetTaskAssetsInfo, useGetTaskWaypointQuery } from '@Api/tasks';
import marker from '@Assets/images/marker.png';
import right from '@Assets/images/rightArrow.png';
import BaseLayerSwitcherUI from '@Components/common/BaseLayerSwitcher';
Expand Down Expand Up @@ -29,6 +29,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
import { useDispatch } from 'react-redux';
import { useParams } from 'react-router-dom';
import ToolTip from '@Components/RadixComponents/ToolTip';
import Skeleton from '@Components/RadixComponents/Skeleton';
import COGOrthophotoViewer from '@Components/common/MapLibreComponents/COGOrthophotoViewer';
import { toast } from 'react-toastify';
import GetCoordinatesOnClick from './GetCoordinatesOnClick';
Expand Down Expand Up @@ -224,6 +225,14 @@ const MapSection = ({ className }: { className?: string }) => {
);
setShowTakeOffPoint(!showTakeOffPoint);
}
const {
data: taskAssetsInformation,
isFetching: taskAssetsInfoLoading,
}: Record<string, any> = useGetTaskAssetsInfo(
projectId as string,
taskId as string,
);

return (
<>
<div
Expand Down Expand Up @@ -330,6 +339,7 @@ const MapSection = ({ className }: { className?: string }) => {
: 'Change Take off Point'}
</Button>
</div>

<div className="naxatw-absolute naxatw-left-[0.575rem] naxatw-top-[5.75rem] naxatw-z-30 naxatw-h-fit">
<Button
variant="ghost"
Expand All @@ -338,28 +348,35 @@ const MapSection = ({ className }: { className?: string }) => {
>
<ToolTip
name="flight_take_off"
message="Show Take Off Point"
message="Show Flight Plan"
symbolType="material-icons"
iconClassName="!naxatw-text-xl !naxatw-text-black naxatw-w-[1.25rem]"
className="naxatw-mt-[-4px]"
/>
</Button>
</div>
<div className="naxatw-absolute naxatw-left-[0.575rem] naxatw-top-[8.25rem] naxatw-z-30 naxatw-h-fit">
<Button
variant="ghost"
className={`naxatw-grid naxatw-h-[1.85rem] naxatw-place-items-center naxatw-border naxatw-bg-[#F5F5F5] !naxatw-px-[0.315rem] ${showOrthoPhotoLayer ? 'naxatw-border-red' : 'naxatw-border-gray-400'}`}
onClick={() => handleOtrhophotoLayerView()}
>
<ToolTip
name="visibility"
message="Show Take Off Point"
symbolType="material-icons"
iconClassName="!naxatw-text-xl !naxatw-text-black"
className="naxatw-mt-[-4px]"
/>
</Button>
</div>

{taskAssetsInfoLoading ? (
<Skeleton className="naxatw-h-[0.5rem] naxatw-w-[0.5rem] naxatw-rounded-sm" />
) : (
taskAssetsInformation?.assets_url && (
<div className="naxatw-absolute naxatw-left-[0.575rem] naxatw-top-[8.25rem] naxatw-z-30 naxatw-h-fit">
<Button
variant="ghost"
className={`naxatw-grid naxatw-h-[1.85rem] naxatw-place-items-center naxatw-border naxatw-bg-[#F5F5F5] !naxatw-px-[0.315rem] ${showOrthoPhotoLayer ? 'naxatw-border-red' : 'naxatw-border-gray-400'}`}
onClick={() => handleOtrhophotoLayerView()}
>
<ToolTip
name="visibility"
message="Show Orthophoto"
symbolType="material-icons"
iconClassName="!naxatw-text-xl !naxatw-text-black"
className="naxatw-mt-[-4px]"
/>
</Button>
</div>
)
)}
<div className="naxatw-absolute naxatw-bottom-3 naxatw-right-[calc(50%-5.4rem)] naxatw-z-30 naxatw-h-fit lg:naxatw-right-3 lg:naxatw-top-3">
<Button
withLoader
Expand Down
17 changes: 15 additions & 2 deletions src/frontend/src/components/UpdateUserDetails/Password/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import { Button } from '@Components/RadixComponents/Button';
import { patchUserProfile } from '@Services/common';
import { useMutation } from '@tanstack/react-query';
import { getLocalStorageValue } from '@Utils/getLocalStorageValue';
import { useNavigate } from 'react-router-dom';

const Password = () => {
const navigate = useNavigate();
const initialState = {
old_password: '',
password: '',
Expand All @@ -30,6 +32,7 @@ const Password = () => {
mutationFn: payloadDataObject => patchUserProfile(payloadDataObject),
onSuccess: () => {
toast.success('Password Updated Successfully');
navigate('/dashboard');
},
onError: err => {
// eslint-disable-next-line no-console
Expand Down Expand Up @@ -74,6 +77,11 @@ const Password = () => {
value: 8,
message: 'Password must have at least 8 characters',
},
validate: {
notSameAsOld: value =>
value !== password ||
'New password cannot be the same as the old password',
},
})}
/>
<ErrorMessage message={formState.errors?.password?.message} />
Expand All @@ -85,8 +93,13 @@ const Password = () => {
className="naxatw-mt-1"
placeholder="Enter confirm password"
{...register('confirm_password', {
validate: (value: string) =>
value === password || 'The passwords do not match',
validate: {
matchPassword: (value: string) =>
value === password || 'The passwords do not match',
notSameAsOld: value =>
value !== password ||
'New password cannot be the same as the old password',
},
// required: 'Confirm Password is Required',
})}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/components/common/UserProfile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function UserProfile() {

return (
<div
className="naxatw-relative"
className="naxatw-relative naxatw-z-50"
tabIndex={0}
onBlur={() => setToggle(false)}
>
Expand Down