From f0732ada8840c0da8a60d4bed45b096e1eb373d5 Mon Sep 17 00:00:00 2001 From: devinleighsmith <41091511+devinleighsmith@users.noreply.github.com> Date: Tue, 18 Jul 2023 10:27:06 -0700 Subject: [PATCH] Psp 6566 map search corrections (#3338) * psp-6566 * correct order of operations for 0 pad. --- source/frontend/src/components/maps/hooks/useMapSearch.tsx | 2 +- .../maps/leaflet/LayerPopup/hooks/useLayerQuery.tsx | 6 ++++-- source/frontend/src/components/maps/leaflet/mapUtils.tsx | 2 ++ .../src/features/properties/map/hooks/useMapProperties.tsx | 2 +- .../src/hooks/pims-api/useFullyAttributedParcelMapLayer.ts | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/source/frontend/src/components/maps/hooks/useMapSearch.tsx b/source/frontend/src/components/maps/hooks/useMapSearch.tsx index 3b6860e8ac..3774892a2f 100644 --- a/source/frontend/src/components/maps/hooks/useMapSearch.tsx +++ b/source/frontend/src/components/maps/hooks/useMapSearch.tsx @@ -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: () => { diff --git a/source/frontend/src/components/maps/leaflet/LayerPopup/hooks/useLayerQuery.tsx b/source/frontend/src/components/maps/leaflet/LayerPopup/hooks/useLayerQuery.tsx index bea511b480..575f21d9cf 100644 --- a/source/frontend/src/components/maps/leaflet/LayerPopup/hooks/useLayerQuery.tsx +++ b/source/frontend/src/components/maps/leaflet/LayerPopup/hooks/useLayerQuery.tsx @@ -167,7 +167,7 @@ export const useLayerQuery = (url: string, authenticated?: boolean): IUserLayerQ requestFunction: useCallback( async (pid: string, allBy?: boolean): Promise> => { //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 = await wfsAxios({ timeout: 20000, authenticated, @@ -188,7 +188,9 @@ export const useLayerQuery = (url: string, authenticated?: boolean): IUserLayerQ const data: AxiosResponse = await wfsAxios({ timeout: 20000, authenticated, - }).get(`${allBy ? baseAllUrl : baseUrl}&${toCqlFilter({ PIN: pin })}`); + }).get( + `${allBy ? baseAllUrl : baseUrl}&${toCqlFilter({ PIN: pin }, true)},`, + ); return data; }, [baseAllUrl, baseUrl, authenticated], diff --git a/source/frontend/src/components/maps/leaflet/mapUtils.tsx b/source/frontend/src/components/maps/leaflet/mapUtils.tsx index f91a30650a..917bfde38e 100644 --- a/source/frontend/src/components/maps/leaflet/mapUtils.tsx +++ b/source/frontend/src/components/maps/leaflet/mapUtils.tsx @@ -270,6 +270,8 @@ export const toCqlFilterValue = (object: Record, 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]}%'`); } diff --git a/source/frontend/src/features/properties/map/hooks/useMapProperties.tsx b/source/frontend/src/features/properties/map/hooks/useMapProperties.tsx index 54f6263f22..1a710b7fe8 100644 --- a/source/frontend/src/features/properties/map/hooks/useMapProperties.tsx +++ b/source/frontend/src/features/properties/map/hooks/useMapProperties.tsx @@ -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}${ diff --git a/source/frontend/src/hooks/pims-api/useFullyAttributedParcelMapLayer.ts b/source/frontend/src/hooks/pims-api/useFullyAttributedParcelMapLayer.ts index 366022a570..17383e968d 100644 --- a/source/frontend/src/hooks/pims-api/useFullyAttributedParcelMapLayer.ts +++ b/source/frontend/src/hooks/pims-api/useFullyAttributedParcelMapLayer.ts @@ -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 },