Skip to content

Commit

Permalink
[Feature] Support search by permit ID on Permit Holders page (#307)
Browse files Browse the repository at this point in the history
* [Feature] Support search by permit ID on Permit Holders page

* Revert accidental processingFee type change
  • Loading branch information
sherryhli committed Jul 30, 2023
1 parent cc0c308 commit a837a72
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/applicants/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const applicants: Resolver<
expiryDateRangeTo = undefined,
search = undefined,
dateOfBirth = undefined,
permitId = undefined,
} = filter;

let expiryDateUpperBound,
Expand Down Expand Up @@ -148,7 +149,11 @@ export const applicants: Resolver<
// Permit status and expiry date range filters both look at the permit expiryDate.
// For this reason we need to filter on expiryDate twice to take both filters in account.
const permitFilter =
expiryDateLowerBound || expiryDateUpperBound || expiryDateRangeFrom || expiryDateRangeTo
expiryDateLowerBound ||
expiryDateUpperBound ||
expiryDateRangeFrom ||
expiryDateRangeTo ||
permitId
? {
some: {
AND: [
Expand All @@ -164,6 +169,11 @@ export const applicants: Resolver<
lte: expiryDateRangeTo?.toISOString(),
},
},
{
rcdPermitId: {
equals: permitId ?? undefined,
},
},
],
},
}
Expand Down
1 change: 1 addition & 0 deletions lib/applicants/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export default gql`
expiryDateRangeTo: Date
search: String
dateOfBirth: Date
permitId: Int
limit: Int
offset: Int
}
Expand Down
1 change: 1 addition & 0 deletions lib/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export type ApplicantsFilter = {
expiryDateRangeTo: Maybe<Scalars['Date']>;
search: Maybe<Scalars['String']>;
dateOfBirth: Maybe<Scalars['Date']>;
permitId: Maybe<Scalars['Int']>;
limit: Maybe<Scalars['Int']>;
offset: Maybe<Scalars['Int']>;
};
Expand Down
24 changes: 24 additions & 0 deletions pages/admin/permit-holders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const PermitHolders: NextPage = () => {
const [searchFilter, setSearchFilter] = useState<string>('');
const { dateRange, addDayToDateRange, dateRangeString } = useDateRangePicker();
const [dateOfBirthFilter, setDateOfBirthFilter] = useState('');
const [permitIdFilter, setPermitIdFilter] = useState<number | null>(null);

// Pagination
const [sortOrder, setSortOrder] = useState<SortOptions>([['name', SortOrder.ASC]]);
Expand All @@ -91,6 +92,7 @@ const PermitHolders: NextPage = () => {
expiryDateRangeTo: dateRange.to?.getTime(),
search: debouncedSearchFilter,
dateOfBirth: dateOfBirthFilter || null,
permitId: permitIdFilter,
offset: pageNumber * PAGE_SIZE,
limit: PAGE_SIZE,
order: sortOrder,
Expand Down Expand Up @@ -351,6 +353,28 @@ const PermitHolders: NextPage = () => {
_focus={{ border: 'none' }}
/>
</HStack>
<HStack
spacing="-12px"
height="2.5rem"
paddingLeft="16px"
border="1px solid"
borderColor="border.secondary"
borderRadius="6px"
>
<Text as="span" textStyle="button-semibold">
Permit ID:
</Text>
<Input
type="number"
placeholder="Permit ID"
fontSize="18px"
width="184px"
value={permitIdFilter !== null ? permitIdFilter : ''}
onChange={event => setPermitIdFilter(event.target.valueAsNumber)}
border="none"
_focus={{ border: 'none' }}
/>
</HStack>
</HStack>
<HStack>
<Menu>
Expand Down

0 comments on commit a837a72

Please sign in to comment.