diff --git a/src/frontend/src/api/tasks.ts b/src/frontend/src/api/tasks.ts index 9cd46ba3..46a31e45 100644 --- a/src/frontend/src/api/tasks.ts +++ b/src/frontend/src/api/tasks.ts @@ -1,5 +1,9 @@ /* eslint-disable import/prefer-default-export */ -import { getIndividualTask, getTaskWaypoint } from '@Services/tasks'; +import { + getIndividualTask, + getTaskAssetsInfo, + getTaskWaypoint, +} from '@Services/tasks'; import { useQuery, UseQueryOptions } from '@tanstack/react-query'; export const useGetTaskWaypointQuery = ( @@ -28,3 +32,17 @@ export const useGetIndividualTaskQuery = ( ...queryOptions, }); }; + +export const useGetTaskAssetsInfo = ( + projectId: string, + taskId: string, + queryOptions?: Partial, +) => { + return useQuery({ + queryKey: ['task-assets-info'], + enabled: !!taskId, + queryFn: () => getTaskAssetsInfo(projectId, taskId), + select: (res: any) => res.data, + ...queryOptions, + }); +}; diff --git a/src/frontend/src/components/DroneOperatorTask/DescriptionSection/DescriptionBox/index.tsx b/src/frontend/src/components/DroneOperatorTask/DescriptionSection/DescriptionBox/index.tsx index 50fc143d..e62a08ea 100644 --- a/src/frontend/src/components/DroneOperatorTask/DescriptionSection/DescriptionBox/index.tsx +++ b/src/frontend/src/components/DroneOperatorTask/DescriptionSection/DescriptionBox/index.tsx @@ -1,10 +1,15 @@ import { useParams } from 'react-router-dom'; -import { useGetIndividualTaskQuery, useGetTaskWaypointQuery } from '@Api/tasks'; +import { + useGetIndividualTaskQuery, + useGetTaskAssetsInfo, + useGetTaskWaypointQuery, +} from '@Api/tasks'; import { useState } from 'react'; // import { useTypedSelector } from '@Store/hooks'; import { format } from 'date-fns'; import DescriptionBoxComponent from './DescriptionComponent'; import QuestionBox from '../QuestionBox'; +import UploadsInformation from '../UploadsInformation'; const DescriptionBox = () => { // const secondPageStates = useTypedSelector(state => state.droneOperatorTask); @@ -21,6 +26,8 @@ const DescriptionBox = () => { }, }, ); + const { data: taskAssetsInformation }: Record = + useGetTaskAssetsInfo(projectId as string, taskId as string); const { data: taskDescription }: Record = useGetIndividualTaskQuery(taskId as string, { @@ -103,7 +110,28 @@ const DescriptionBox = () => { ))} {/* {!secondPage && } */} - + + + {taskAssetsInformation?.image_count > 0 && ( +
+ +
+ )} ); }; diff --git a/src/frontend/src/components/DroneOperatorTask/DescriptionSection/QuestionBox/index.tsx b/src/frontend/src/components/DroneOperatorTask/DescriptionSection/QuestionBox/index.tsx index 7189aa1d..0eb87ec2 100644 --- a/src/frontend/src/components/DroneOperatorTask/DescriptionSection/QuestionBox/index.tsx +++ b/src/frontend/src/components/DroneOperatorTask/DescriptionSection/QuestionBox/index.tsx @@ -12,9 +12,14 @@ import UploadsBox from '../UploadsBox'; interface IQuestionBoxProps { flyable: string; setFlyable: React.Dispatch>; + haveNoImages: boolean; } -const QuestionBox = ({ flyable, setFlyable }: IQuestionBoxProps) => { +const QuestionBox = ({ + flyable, + setFlyable, + haveNoImages, +}: IQuestionBoxProps) => { const { projectId, taskId } = useParams(); const dispatch = useTypedDispatch(); @@ -119,7 +124,7 @@ const QuestionBox = ({ flyable, setFlyable }: IQuestionBoxProps) => { - {flyable === 'yes' && } + {flyable === 'yes' && haveNoImages && } ); diff --git a/src/frontend/src/components/DroneOperatorTask/DescriptionSection/UploadsBox/index.tsx b/src/frontend/src/components/DroneOperatorTask/DescriptionSection/UploadsBox/index.tsx index a57e1718..4df0ea89 100644 --- a/src/frontend/src/components/DroneOperatorTask/DescriptionSection/UploadsBox/index.tsx +++ b/src/frontend/src/components/DroneOperatorTask/DescriptionSection/UploadsBox/index.tsx @@ -3,7 +3,7 @@ /* eslint-disable no-unused-vars */ import { Button } from '@Components/RadixComponents/Button'; import { toggleModal } from '@Store/actions/common'; -import { setFiles, showPopover } from '@Store/actions/droneOperatorTask'; +import { setFiles } from '@Store/actions/droneOperatorTask'; import { useTypedDispatch, useTypedSelector } from '@Store/hooks'; const UploadsBox = () => { diff --git a/src/frontend/src/components/DroneOperatorTask/DescriptionSection/UploadsInformation/index.tsx b/src/frontend/src/components/DroneOperatorTask/DescriptionSection/UploadsInformation/index.tsx new file mode 100644 index 00000000..0a86a0e5 --- /dev/null +++ b/src/frontend/src/components/DroneOperatorTask/DescriptionSection/UploadsInformation/index.tsx @@ -0,0 +1,29 @@ +const UploadsInformation = ({ data }: { data: Record[] }) => { + return ( + <> +
+
+

+ Upload Information +

+
+ + {data.map(information => ( +
+

+ {information?.name} +

+

:

+

+ {information?.value} +

+
+ ))} +
+ + ); +}; +export default UploadsInformation; diff --git a/src/frontend/src/components/DroneOperatorTask/DescriptionSection/index.tsx b/src/frontend/src/components/DroneOperatorTask/DescriptionSection/index.tsx index 0120f319..9e205376 100644 --- a/src/frontend/src/components/DroneOperatorTask/DescriptionSection/index.tsx +++ b/src/frontend/src/components/DroneOperatorTask/DescriptionSection/index.tsx @@ -96,7 +96,7 @@ const DroneOperatorDescriptionBox = () => { const handleDownloadFlightPlan = () => { fetch( `${BASE_URL}/waypoint/task/${taskId}/?project_id=${projectId}&download=true`, - {"method":'POST'} + { method: 'POST' }, ) .then(response => { if (!response.ok) { diff --git a/src/frontend/src/services/tasks.ts b/src/frontend/src/services/tasks.ts index daa54213..67561a69 100644 --- a/src/frontend/src/services/tasks.ts +++ b/src/frontend/src/services/tasks.ts @@ -7,3 +7,6 @@ export const getTaskWaypoint = (projectId: string, taskId: string) => export const getIndividualTask = (taskId: string) => authenticated(api).get(`/tasks/${taskId}`); + +export const getTaskAssetsInfo = (projectId: string, taskId: string) => + authenticated(api).get(`/projects/assets/${projectId}/${taskId}/`);