Skip to content

Commit e6e0b13

Browse files
authored
ORV2-3412 - FE: Staff Search for Permit by VIN (#1815)
Co-authored-by: GlenAOT <[email protected]>
1 parent c2f081b commit e6e0b13

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

frontend/src/common/components/header/components/SearchFilter.tsx

+18-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { getDefaultRequiredVal } from "../../../helpers/util";
2424
import { IDIR_ROUTES } from "../../../../routes/constants";
2525
import { Nullable } from "../../../types/common";
2626
import {
27+
SEARCH_BY_FILTERS,
2728
SearchByFilter,
2829
SearchEntity,
2930
SearchFields,
@@ -34,6 +35,7 @@ import OnRouteBCContext from "../../../authentication/OnRouteBCContext";
3435
const SEARCH_BY_PERMIT_OPTIONS = [
3536
{ label: "Permit Number", value: "permitNumber" },
3637
{ label: "Plate Number", value: "plate" },
38+
{ label: "VIN (last 6 digits)", value: "vin" },
3739
];
3840

3941
const SEARCH_BY_COMPANY_OPTIONS = [
@@ -118,7 +120,9 @@ export const SearchFilter = ({
118120
reValidateMode: "onBlur",
119121
});
120122

121-
const { handleSubmit, setValue, control } = formMethods;
123+
const { handleSubmit, setValue, control, watch } = formMethods;
124+
125+
const searchByFilter = watch("searchByFilter");
122126

123127
const handleSearchEntityChange = (searchEntity: string) => {
124128
setValue("searchEntity", searchEntity as SearchEntity);
@@ -128,11 +132,13 @@ export const SearchFilter = ({
128132
"searchByFilter",
129133
updatedSearchByOptions[0].value as SearchByFilter,
130134
);
135+
setValue("searchString", "");
131136
};
132137

133138
const handleSearchByChange = (event: SelectChangeEvent) => {
134139
const searchBy = event.target.value;
135140
setValue("searchByFilter", searchBy as SearchByFilter);
141+
setValue("searchString", "");
136142
};
137143

138144
const handleSearchValueChange = (
@@ -142,6 +148,12 @@ export const SearchFilter = ({
142148
setValue("searchString", searchString);
143149
};
144150

151+
const handleSearchValueKeyDown = (event: React.KeyboardEvent) => {
152+
if (event.key === "Enter") {
153+
handleSubmit(onSubmit)();
154+
}
155+
};
156+
145157
const onSubmit = (data: FieldValues) => {
146158
const searchFields = Object.entries(data)
147159
.map(([key, value]) => `${key}=${value}`)
@@ -231,7 +243,11 @@ export const SearchFilter = ({
231243
className="search-by__value"
232244
value={value}
233245
onChange={handleSearchValueChange}
234-
inputProps={{ maxLength: 100 }}
246+
onKeyDown={handleSearchValueKeyDown}
247+
inputProps={{
248+
maxLength:
249+
searchByFilter === SEARCH_BY_FILTERS.VIN ? 6 : 100,
250+
}}
235251
/>
236252
)}
237253
/>

frontend/src/features/idir/search/pages/IDIRSearchResultsDashboard.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ const getBannerText = (searchFields: SearchFields): string => {
2525
if (searchByFilter === SEARCH_BY_FILTERS.PERMIT_NUMBER) {
2626
return `Search Results: Permit # ${searchString}`;
2727
}
28+
if (searchByFilter === SEARCH_BY_FILTERS.VIN) {
29+
return `Search Results: VIN ${searchString}`;
30+
}
2831
return "";
2932
};
3033

frontend/src/features/idir/search/table/PermitSearchResultColumnDef.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ export const PermitSearchResultColumnDef = (
9797
sortingFn: "alphanumeric",
9898
size: 20,
9999
},
100+
{
101+
accessorKey: "vin",
102+
header: "VIN (last 6 digits)",
103+
enableSorting: true,
104+
sortingFn: "alphanumeric",
105+
size: 20,
106+
},
100107
{
101108
accessorKey: "legalName",
102109
header: "Company Name",

frontend/src/features/idir/search/types/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const SEARCH_BY_FILTERS = {
1919
COMPANY_NAME: "companyName",
2020
ONROUTEBC_CLIENT_NUMBER: "onRouteBCClientNumber",
2121
APPLICATION_NUMBER: "applicationNumber",
22+
VIN: "vin",
2223
} as const;
2324

2425
export type SearchByFilter =

0 commit comments

Comments
 (0)