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] Sort permit past applications #378

Merged
merged 4 commits into from
Nov 25, 2024
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
13 changes: 10 additions & 3 deletions components/admin/permit-holders/app-history/Card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@ export default function AppHistoryCard({ appHistory }: Props) {
spacing="16px"
divider={<StackDivider borderColor="border.secondary" />}
>
{appHistory.map(permit => (
<AppHistoryRecord key={permit.application.id} permit={permit} />
))}
{appHistory
.slice()
.sort(function (a: PermitRecord, b: PermitRecord) {
const aCreated = a.application.createdAt;
const bCreated = b.application.createdAt;
return aCreated < bCreated ? 1 : aCreated > bCreated ? -1 : 0;
})
.map(permit => (
<AppHistoryRecord key={permit.application.id} permit={permit} />
))}
</VStack>
</PermitHolderInfoCard>
);
Expand Down
4 changes: 2 additions & 2 deletions tools/admin/permit-holders/app-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Application, ApplicationProcessing, Invoice, Permit } from '@lib/graphq

/** APP history entry record (API response) */
export type AppHistoryRecord = Pick<Permit, 'rcdPermitId' | 'expiryDate'> & {
application: Pick<Application, 'id' | 'type' | 'permitType'> & {
application: Pick<Application, 'id' | 'type' | 'permitType' | 'createdAt'> & {
processing: Pick<ApplicationProcessing, 'documentsUrl' | 'documentsS3ObjectKey'> & {
invoice: Pick<Invoice, 's3ObjectUrl' | 's3ObjectKey'>;
};
Expand All @@ -11,7 +11,7 @@ export type AppHistoryRecord = Pick<Permit, 'rcdPermitId' | 'expiryDate'> & {

/** APP history entry row in APP history card (FE) */
export type PermitRecord = Pick<Permit, 'rcdPermitId' | 'expiryDate'> & {
application: Pick<Application, 'id' | 'type' | 'permitType'> & {
application: Pick<Application, 'id' | 'type' | 'permitType' | 'createdAt'> & {
processing: Pick<ApplicationProcessing, 'documentsUrl' | 'documentsS3ObjectKey'> & {
invoice: Pick<Invoice, 's3ObjectUrl' | 's3ObjectKey'>;
};
Expand Down
1 change: 1 addition & 0 deletions tools/admin/permit-holders/view-permit-holder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export const GET_APPLICANT_QUERY = gql`
id
type
permitType
createdAt
processing {
documentsUrl
documentsS3ObjectKey
Expand Down
Loading