From d98938d27372dad5b4b6522cf41b7ebe55a0653f Mon Sep 17 00:00:00 2001 From: Smith Date: Fri, 5 Jul 2024 12:00:52 -0700 Subject: [PATCH] psp-8018: display retired warning immediately upon add. --- .../PropertySelectorSearchContainer.tsx | 26 +++++++++++++++---- .../SelectedPropertyRow.tsx | 5 ++++ source/frontend/src/utils/mapPropertyUtils.ts | 10 +++---- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/source/frontend/src/components/propertySelector/search/PropertySelectorSearchContainer.tsx b/source/frontend/src/components/propertySelector/search/PropertySelectorSearchContainer.tsx index 7a02fbe5c3..a7787fc616 100644 --- a/source/frontend/src/components/propertySelector/search/PropertySelectorSearchContainer.tsx +++ b/source/frontend/src/components/propertySelector/search/PropertySelectorSearchContainer.tsx @@ -9,6 +9,7 @@ import { LocationFeatureDataset } from '@/components/common/mapFSM/useLocationFe import { IGeocoderResponse } from '@/hooks/pims-api/interfaces/IGeocoder'; import { useAdminBoundaryMapLayer } from '@/hooks/repositories/mapLayer/useAdminBoundaryMapLayer'; import { useFullyAttributedParcelMapLayer } from '@/hooks/repositories/mapLayer/useFullyAttributedParcelMapLayer'; +import { usePimsPropertyLayer } from '@/hooks/repositories/mapLayer/usePimsPropertyLayer'; import { useGeocoderRepository } from '@/hooks/useGeocoderRepository'; import { MOT_DistrictBoundary_Feature_Properties } from '@/models/layers/motDistrictBoundary'; import { MOT_RegionalBoundary_Feature_Properties } from '@/models/layers/motRegionalBoundary'; @@ -32,6 +33,9 @@ export const PropertySelectorSearchContainer: React.FC([]); const [addressResults, setAddressResults] = useState([]); + const pimsPropertyLayerService = usePimsPropertyLayer(); + const loadPimsProperties = pimsPropertyLayerService.loadPropertyLayer.execute; + const { getSitePids, isLoadingSitePids, @@ -87,17 +91,28 @@ export const PropertySelectorSearchContainer: React.FC { + return loadPimsProperties({ + PID: p?.properties?.PID_NUMBER?.toString(), + PIN: p?.properties?.PIN?.toString(), + }); + }); + const addressResults = await Promise.all(getAddressTasks); const regionDistrictResults = await Promise.all(matchTasks); + const pimsResults = await Promise.all(getPimsTasks); + const locations = result.features.map((p, i) => { const foundProperty = featureToLocationFeatureDataset(p); foundProperty.regionFeature = regionDistrictResults[i]?.regionFeature; foundProperty.districtFeature = regionDistrictResults[i]?.districtFeature; - foundProperty.pimsFeature = { - properties: { - STREET_ADDRESS_1: addressResults[i]?.fullAddress, - }, - } as Feature; + foundProperty.pimsFeature = pimsResults[i]?.features?.length + ? pimsResults[i]?.features[0] + : ({ + properties: { + STREET_ADDRESS_1: addressResults[i]?.fullAddress, + }, + } as Feature); return foundProperty; }) as LocationFeatureDataset[]; setSearchResults(locations); @@ -116,6 +131,7 @@ export const PropertySelectorSearchContainer: React.FC { diff --git a/source/frontend/src/components/propertySelector/selectedPropertyList/SelectedPropertyRow.tsx b/source/frontend/src/components/propertySelector/selectedPropertyList/SelectedPropertyRow.tsx index cf992b7c22..67113c1dd7 100644 --- a/source/frontend/src/components/propertySelector/selectedPropertyList/SelectedPropertyRow.tsx +++ b/source/frontend/src/components/propertySelector/selectedPropertyList/SelectedPropertyRow.tsx @@ -1,3 +1,4 @@ +import { getIn, useFormikContext } from 'formik'; import { Col, Row } from 'react-bootstrap'; import { RemoveButton } from '@/components/common/buttons'; @@ -18,6 +19,10 @@ export interface ISelectedPropertyRowProps { export const SelectedPropertyRow: React.FunctionComponent< React.PropsWithChildren > = ({ nameSpace, onRemove, index, property }) => { + const { setFieldTouched, touched } = useFormikContext(); + if (getIn(touched, `${nameSpace}.name`) !== true) { + setFieldTouched(`${nameSpace}.name`); + } const propertyName = getPropertyName(property); let propertyIdentifier = ''; switch (propertyName.label) { diff --git a/source/frontend/src/utils/mapPropertyUtils.ts b/source/frontend/src/utils/mapPropertyUtils.ts index e7e1833bdd..4e89676aa1 100644 --- a/source/frontend/src/utils/mapPropertyUtils.ts +++ b/source/frontend/src/utils/mapPropertyUtils.ts @@ -22,7 +22,7 @@ import { ApiGen_CodeTypes_GeoJsonTypes } from '@/models/api/generated/ApiGen_Cod import { ApiGen_Concepts_FileProperty } from '@/models/api/generated/ApiGen_Concepts_FileProperty'; import { ApiGen_Concepts_Geometry } from '@/models/api/generated/ApiGen_Concepts_Geometry'; import { ApiGen_Concepts_Property } from '@/models/api/generated/ApiGen_Concepts_Property'; -import { enumFromValue, exists, formatApiAddress, pidFormatter } from '@/utils'; +import { exists, formatApiAddress, isValidId, pidFormatter } from '@/utils'; export enum NameSourceType { PID = 'PID', @@ -260,11 +260,9 @@ export function pidFromFeatureSet(featureset: LocationFeatureDataset): string | } export function pinFromFeatureSet(featureset: LocationFeatureDataset): string | null { - return ( - featureset?.pimsFeature?.properties?.PIN?.toString() ?? - featureset?.parcelFeature?.properties?.PIN?.toString() ?? - null - ); + return isValidId(featureset?.pimsFeature?.properties?.PIN) + ? featureset?.parcelFeature?.properties?.PIN?.toString() + : null; } export function locationFromFileProperty(