Skip to content

Commit

Permalink
Adjust project description as per regulator's approval status (#361)
Browse files Browse the repository at this point in the history
* feat: Implement S3 path structure & file upload for user-specific drone operator certificate uploads

* refac: refactor user profile update: Add validation for empty data, handle certificate URL and role updates

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* feat: update certificate URL in database for user profile

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* feat: update registration registration of drone operator

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix(profile-update): UI Issue

* feat: add method parameter on `callApiSimultaneously` function

* feat(update-profile): post add files `certificate` and `drone registration` file along with the other details

* feat: post drone registered certificate and drone pilot certificate on profile complete

* feat: show default image on profile in case of failure

* feat(update-profile): post only the binary file on certificate

* feat: add `@cyntler/react-doc-viewer` package

* feat: add document preview modal

* feat(dashboard): implement drone certificate preview on task lock request

* fix(individual-project): task requested for lock although the project owner lockes the task

* feat: set certificate & registration url in my-info endpoint

* fix: document viewer details style

* fix: UploadArea component

* feat: show uploaded certificates on edit profile page

* feat: clear selectedDocumentDetails on document preview component unmount

* feat(document-preview): download certificate using blob and additional UI  if the file is image

* feat: set the certificate & registration url in task request page

* feat(dashboard): show drone certificate and pilot certificate on task request log

* feat: ommit password section if the existing user is trying to login as another role

* fix: remove comment code from task schemas

* feat(regulators-approval-page): clear local storage on main page unmount

* fix: set iscertifiedDroneUser initial value once

* feat(user-profile): support pdf to upload certificates

* feat(project-approval-page): clear comment on approval comment success

* feat: make project `DescriptionSection` dynamic to render on both project description and project approval page

* feat: add about section on project description page

* feat: make regulator approval status optional to view on description section

* feat(project-description): make map popup disabled if the regulator approval status is `REJECTED`

* feat(project-description): disable popup open on table row click if requlator approval status is `REJECTED`

---------

Co-authored-by: Pradip-p <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sujit <[email protected]>
  • Loading branch information
4 people authored Nov 28, 2024
1 parent 137ce1b commit 206dd79
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,11 @@ const MapSection = ({ projectData }: { projectData: Record<string, any> }) => {
title={`Task #${selectedTaskId}`}
showPopup={(feature: Record<string, any>) => {
if (!userDetails) return false;

return (
feature?.source?.includes('tasks-layer') &&
!userDetails?.role?.includes('REGULATOR') // Don't show popup if user role is regulator
!userDetails?.role?.includes('REGULATOR') && // Don't show popup if user role is regulator
projectData?.regulator_approval_status !== 'REJECTED' // Don't show popup if regulator rejected the approval
);
}}
fetchPopupData={(properties: Record<string, any>) => {
Expand Down Expand Up @@ -301,7 +303,11 @@ const MapSection = ({ projectData }: { projectData: Record<string, any> }) => {
secondaryButtonText="Unlock Task"
handleSecondaryBtnClick={() => handleTaskUnLockClick()}
// trigger from popup outside
openPopupFor={taskClickedOnTable}
openPopupFor={
projectData?.regulator_approval_status === 'REJECTED' // ignore click if the regulator rejected the approval
? null
: taskClickedOnTable
}
popupCoordinate={taskClickedOnTable?.centroidCoordinates}
onClose={() =>
dispatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const ApprovalSection = () => {
mutationFn: regulatorComment,
onSuccess: () => {
toast.success('Responded successfully');
setComment('');
},
onError: (err: any) => {
toast.error(err?.response?.data?.detail || err?.message || '');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import ApprovalSection from './ApprovalSection';

const DescriptionSection = ({
page = 'project-approval',
projectData,
}: {
projectData: Record<string, any>;
page?: 'project-description' | 'project-approval';
}) => {
return (
<div className="naxatw-mt-4 naxatw-flex naxatw-flex-col naxatw-gap-3">
<p className="naxatw-text-[0.875rem] naxatw-font-semibold naxatw-leading-normal naxatw-tracking-[0.0175rem] naxatw-text-[#D73F3F]">
Description
</p>
{page === 'project-approval' && (
<p className="naxatw-text-[0.875rem] naxatw-font-semibold naxatw-leading-normal naxatw-tracking-[0.0175rem] naxatw-text-[#D73F3F]">
Description
</p>
)}
<div className="naxatw-flex naxatw-flex-col naxatw-gap-3 naxatw-text-sm">
<p>{projectData?.description || ''}</p>
<div className="naxatw-flex naxatw-flex-col naxatw-gap-1">
Expand Down Expand Up @@ -45,16 +49,18 @@ const DescriptionSection = ({
</p>
</div>
)}
<div className="naxatw-flex naxatw-gap-2">
<p className="naxatw-w-[118px]">Regulator Approval Status</p>
<p>:</p>{' '}
<p className="naxatw-font-semibold">
{projectData?.regulator_approval_status || ''}
</p>
</div>
{projectData?.regulator_approval_status && (
<div className="naxatw-flex naxatw-gap-2">
<p className="naxatw-w-[118px]">Regulator Approval Status</p>
<p>:</p>{' '}
<p className="naxatw-font-semibold">
{projectData?.regulator_approval_status || ''}
</p>
</div>
)}
</div>
</div>
<ApprovalSection />
{page === 'project-approval' && <ApprovalSection />}
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ const OtherDetails = () => {
: 'no',
}),
);
}, [userProfile, dispatch]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const onSubmit = (formData: Record<string, any>) => {
updateOtherDetails({
Expand Down
5 changes: 5 additions & 0 deletions src/frontend/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export const tabOptions = [
];

export const projectOptions = [
{
id: 0,
label: 'About',
value: 'about',
},
{
id: 1,
label: 'AVAILABLE TASKS',
Expand Down
3 changes: 3 additions & 0 deletions src/frontend/src/views/IndividualProject/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Tasks,
} from '@Components/IndividualProject';
import Skeleton from '@Components/RadixComponents/Skeleton';
import DescriptionSection from '@Components/RegulatorsApprovalPage/Description/DescriptionSection';
import { projectOptions } from '@Constants/index';
import { setProjectState } from '@Store/actions/project';
import { useTypedDispatch, useTypedSelector } from '@Store/hooks';
Expand All @@ -25,6 +26,8 @@ const getActiveTabContent = (
// eslint-disable-next-line no-unused-vars
handleTableRowClick: (rowData: any) => {},
) => {
if (activeTab === 'about')
return <DescriptionSection projectData={data} page="project-description" />;
if (activeTab === 'tasks')
return (
<Tasks
Expand Down

0 comments on commit 206dd79

Please sign in to comment.