Skip to content

Commit

Permalink
Psp 6566 map search corrections (#3338)
Browse files Browse the repository at this point in the history
* psp-6566

* correct order of operations for 0 pad.
  • Loading branch information
devinleighsmith authored Jul 18, 2023
1 parent 7f0db83 commit f0732ad
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion source/frontend/src/components/maps/hooks/useMapSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const useMapSearch = () => {
setModalContent({
title: 'Unable to connect to PIMS Inventory',
message:
'PIMS is unable to connect to connect to the PIMS Inventory map service. You may need to log out and log into the application in order to restore this functionality. If this error persists, contact a site administrator.',
'PIMS is unable to connect to the PIMS Inventory map service. You may need to log out and log into the application in order to restore this functionality. If this error persists, contact a site administrator.',
okButtonText: 'Log out',
cancelButtonText: 'Continue working',
handleOk: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const useLayerQuery = (url: string, authenticated?: boolean): IUserLayerQ
requestFunction: useCallback(
async (pid: string, allBy?: boolean): Promise<AxiosResponse<FeatureCollection>> => {
//Do not make a request if we our currently cached response matches the requested pid.
const formattedPid = pid.replace(/-/g, '');
const formattedPid = pid.replace(/[-\s]/g, '').padStart(9, '0');
const data: AxiosResponse<FeatureCollection> = await wfsAxios({
timeout: 20000,
authenticated,
Expand All @@ -188,7 +188,9 @@ export const useLayerQuery = (url: string, authenticated?: boolean): IUserLayerQ
const data: AxiosResponse<FeatureCollection> = await wfsAxios({
timeout: 20000,
authenticated,
}).get<FeatureCollection>(`${allBy ? baseAllUrl : baseUrl}&${toCqlFilter({ PIN: pin })}`);
}).get<FeatureCollection>(
`${allBy ? baseAllUrl : baseUrl}&${toCqlFilter({ PIN: pin }, true)},`,
);
return data;
},
[baseAllUrl, baseUrl, authenticated],
Expand Down
2 changes: 2 additions & 0 deletions source/frontend/src/components/maps/leaflet/mapUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ export const toCqlFilterValue = (object: Record<string, string>, flags?: IWfsCql
flags?.forceExactMatch
) {
cql.push(`${key} = '${object[key]}'`);
} else if (key === 'PIN' && flags?.forceExactMatch) {
cql.push(`${key}=${object[key].replace(/[^0-9]/g, '')}`);
} else {
cql.push(`${key} ilike '%${object[key]}%'`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const useMapProperties = () => {
(params?: IGeoSearchParams) => {
const geoserver_params = {
STREET_ADDRESS_1: params?.STREET_ADDRESS_1,
PID_PADDED: params?.PID,
PID_PADDED: params?.PID?.replace(/[-\s]/g, ''),
PIN: params?.PIN,
};
const url = `${propertiesUrl}${
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const useFullyAttributedParcelMapLayer = (url: string, name: string) => {
const findByPid = useCallback(
async (pid: string, forceExactMatch = false) => {
// Removes dashes to match expectations of the map layer.
const formattedPid = pid.replace(/-/g, '');
const formattedPid = pid.replace(/[-\s]/g, '');
const data = await getAllFeatures(
{ PID: formattedPid },
{ forceExactMatch: forceExactMatch, timeout: 30000 },
Expand Down

0 comments on commit f0732ad

Please sign in to comment.