Skip to content

Commit

Permalink
Remove applicant deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
ChinemeremChigbo committed Nov 17, 2024
1 parent 449f83a commit 4be8bef
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 22 deletions.
19 changes: 11 additions & 8 deletions components/admin/permit-holders/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ type PermitHolderHeaderProps = {
status: ApplicantStatus;
inactiveReason?: string;
notes: string;
mostRecentApplication?: Pick<Application, 'processing'>;
};
readonly refetch: () => void;
};

export default function PermitHolderHeader({
applicant: { id, name, status, inactiveReason, notes },
applicant: { id, name, status, inactiveReason, notes, mostRecentApplication },
refetch,
}: PermitHolderHeaderProps) {
const router = useRouter();
Expand Down Expand Up @@ -108,13 +109,15 @@ export default function PermitHolderHeader({
>
{`Set as ${status === 'ACTIVE' ? 'Inactive' : 'Active'}`}
</MenuItem>
<MenuItem
color="text.critical"
textStyle="button-regular"
onClick={onOpenDeleteApplicantModal}
>
{'Delete Permit Holder'}
</MenuItem>
{mostRecentApplication?.processing?.status == 'COMPLETED' ? null : (
<MenuItem
color="text.critical"
textStyle="button-regular"
onClick={onOpenDeleteApplicantModal}
>
{'Delete Permit Holder'}
</MenuItem>
)}
</MenuList>
</Menu>
</Box>
Expand Down
1 change: 1 addition & 0 deletions pages/admin/permit-holder/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default function PermitHolder({ id: idString }: Props) {
status,
inactiveReason: inactiveReason || undefined,
notes: notes || '',
mostRecentApplication: currentApplication,
}}
refetch={refetch}
/>
Expand Down
36 changes: 22 additions & 14 deletions pages/admin/permit-holders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
} from '@chakra-ui/react'; // Chakra UI
import { ChevronDownIcon, SearchIcon, WarningIcon, WarningTwoIcon } from '@chakra-ui/icons'; // Chakra UI Icons
import Layout from '@components/admin/Layout'; // Layout component
import { ApplicantStatus, PermitStatus } from '@lib/graphql/types'; // Types
import { ApplicantStatus, PermitStatus, Application } from '@lib/graphql/types'; // Types
import { authorize } from '@tools/authorization'; // Page authorization
import Table from '@components/Table'; // Table component
import Pagination from '@components/Pagination'; // Pagination component
Expand Down Expand Up @@ -273,10 +273,16 @@ const PermitHolders: NextPage = () => {
Header: 'Actions',
Cell: ({
row: {
original: { id, status },
original: { id, status, mostRecentApplication },
},
}: {
row: { original: { id: number; status: ApplicantStatus } };
row: {
original: {
id: number;
status: ApplicantStatus;
mostRecentApplication?: Pick<Application, 'processing'>;
};
};
}) => {
return (
<Menu>
Expand All @@ -301,17 +307,19 @@ const PermitHolders: NextPage = () => {
>
{`Set as ${status === 'ACTIVE' ? 'Inactive' : 'Active'}`}
</MenuItem>
<MenuItem
color="text.critical"
textStyle="button-regular"
onClick={event => {
event.stopPropagation();
setPermitHolderToDelete(id);
onOpenDeleteApplicantModal();
}}
>
{'Delete Permit Holder'}
</MenuItem>
{mostRecentApplication?.processing?.status == 'COMPLETED' ? null : (
<MenuItem
color="text.critical"
textStyle="button-regular"
onClick={event => {
event.stopPropagation();
setPermitHolderToDelete(id);
onOpenDeleteApplicantModal();
}}
>
{'Delete Permit Holder'}
</MenuItem>
)}
</MenuList>
</Menu>
);
Expand Down
8 changes: 8 additions & 0 deletions tools/admin/permit-holders/permit-holders-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
SetApplicantAsInactiveResult,
MutationSetApplicantAsActiveArgs,
SetApplicantAsActiveResult,
Application,
} from '@lib/graphql/types';

/** Array of permit statuses */
Expand Down Expand Up @@ -41,6 +42,7 @@ export type PermitHolderRow = Pick<Applicant, 'id' | 'dateOfBirth' | 'phone' | '
postalCode: string;
};
mostRecentPermit: Pick<Permit, 'expiryDate' | 'rcdPermitId'>;
mostRecentApplication: Pick<Application, 'processing'>;
};

/**
Expand Down Expand Up @@ -70,6 +72,11 @@ export const GET_PERMIT_HOLDERS_QUERY = gql`
rcdPermitId
}
status
mostRecentApplication {
processing {
status
}
}
}
totalCount
}
Expand All @@ -95,6 +102,7 @@ export type PermitHolder = Pick<
| 'status'
> & {
mostRecentPermit: Pick<Permit, 'expiryDate' | 'rcdPermitId'>;
mostRecentApplication: Pick<Application, 'processing'>;
};

export type GetPermitHoldersResponse = {
Expand Down

0 comments on commit 4be8bef

Please sign in to comment.