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

[Improvement] Remove completed request deletion #386

Merged
merged 1 commit into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 12 additions & 7 deletions components/admin/requests/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { titlecase } from '@tools/string';
import { formatDateYYYYMMDD, formatDateYYYYMMDDLocal } from '@lib/utils/date';
import { getPermanentPermitExpiryDate } from '@lib/utils/permit-expiry';
import { useEffect, useState } from 'react'; // React
import { CurrentApplication } from '@tools/admin/permit-holders/current-application';

type RequestHeaderProps = {
readonly id: number;
Expand All @@ -39,6 +40,7 @@ type RequestHeaderProps = {
readonly permitExpiry: Date | null;
readonly temporaryPermitExpiry: Date | null;
readonly reasonForRejection?: string;
readonly mostRecentApplication: CurrentApplication | null;
};

/**
Expand Down Expand Up @@ -67,6 +69,7 @@ export default function RequestHeader({
permitExpiry,
temporaryPermitExpiry,
reasonForRejection,
mostRecentApplication,
}: RequestHeaderProps) {
const displayShopifyUrl = paidThroughShopify && shopifyOrderID && shopifyOrderNumber;
const shopifyOrderUrl = `https://${process.env.NEXT_PUBLIC_SHOPIFY_DOMAIN}/admin/orders/${shopifyOrderID}`;
Expand Down Expand Up @@ -149,13 +152,15 @@ export default function RequestHeader({
<Text textStyle="caption">More Actions</Text>
</MenuButton>
<MenuList>
<MenuItem
color="text.critical"
textStyle="button-regular"
onClick={onOpenDeleteApplicationModal}
>
{'Delete Request'}
</MenuItem>
{mostRecentApplication?.processing?.status == 'COMPLETED' ? null : (
<MenuItem
color="text.critical"
textStyle="button-regular"
onClick={onOpenDeleteApplicationModal}
>
{'Delete Request'}
</MenuItem>
)}
</MenuList>
</Menu>
</HStack>
Expand Down
4 changes: 4 additions & 0 deletions pages/admin/request/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
} from '@tools/admin/requests/view-request'; // Request page GraphQL queries
import ReasonForReplacementCard from '@components/admin/requests/reason-for-replacement/Card';
import GuardianInformationCard from '@components/admin/requests/guardian-information/Card';
import { CurrentApplication } from '@tools/admin/permit-holders/current-application';

type Props = {
readonly id: string;
Expand Down Expand Up @@ -65,6 +66,8 @@ const Request: NextPage<Props> = ({ id: idString }: Props) => {

// Get expiry date to display
const mostRecentPermitExpiryDate = data.application.applicant?.mostRecentPermit?.expiryDate;
const mostRecentApplication: CurrentApplication | null =
data.application.applicant?.mostRecentApplication;
const permitExpiry =
type === 'REPLACEMENT' ? mostRecentPermitExpiryDate : permit ? permit.expiryDate : null;

Expand Down Expand Up @@ -97,6 +100,7 @@ const Request: NextPage<Props> = ({ id: idString }: Props) => {
permitExpiry={permitExpiry}
temporaryPermitExpiry={temporaryPermitExpiry || null}
reasonForRejection={rejectedReason || undefined}
mostRecentApplication={mostRecentApplication}
/>
</GridItem>
<GridItem colStart={1} colSpan={5} textAlign="left">
Expand Down
7 changes: 7 additions & 0 deletions tools/admin/requests/view-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
QueryApplicationArgs,
Permit,
} from '@lib/graphql/types';
import { CurrentApplication } from '@tools/admin/permit-holders/current-application';

// Queries an Application by ID along with the associated permit, replacement, applicationProcessing, and applicant
export const GET_APPLICATION_QUERY = gql`
Expand Down Expand Up @@ -43,6 +44,11 @@ export const GET_APPLICATION_QUERY = gql`
mostRecentPermit {
expiryDate
}
mostRecentApplication {
processing {
status
}
}
}
permit {
expiryDate
Expand Down Expand Up @@ -82,6 +88,7 @@ export type GetApplicationResponse = {
};
applicant: Pick<Applicant, 'id'> & {
mostRecentPermit: Pick<Permit, 'expiryDate'> | null;
mostRecentApplication: CurrentApplication | null;
};
temporaryPermitExpiry?: Date;
permit: Pick<Permit, 'expiryDate'> | null;
Expand Down
Loading