Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

psp-8018: display retired warning immediately upon add. #4164

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -32,6 +33,9 @@ export const PropertySelectorSearchContainer: React.FC<IPropertySelectorSearchCo
const [searchResults, setSearchResults] = useState<LocationFeatureDataset[]>([]);
const [addressResults, setAddressResults] = useState<IGeocoderResponse[]>([]);

const pimsPropertyLayerService = usePimsPropertyLayer();
const loadPimsProperties = pimsPropertyLayerService.loadPropertyLayer.execute;

const {
getSitePids,
isLoadingSitePids,
Expand Down Expand Up @@ -87,17 +91,28 @@ export const PropertySelectorSearchContainer: React.FC<IPropertySelectorSearchCo
);
});

const getPimsTasks = result.features.map(p => {
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<Geometry, PIMS_Property_Location_View>;
foundProperty.pimsFeature = pimsResults[i]?.features?.length
? pimsResults[i]?.features[0]
: ({
properties: {
STREET_ADDRESS_1: addressResults[i]?.fullAddress,
},
} as Feature<Geometry, PIMS_Property_Location_View>);
return foundProperty;
}) as LocationFeatureDataset[];
setSearchResults(locations);
Expand All @@ -116,6 +131,7 @@ export const PropertySelectorSearchContainer: React.FC<IPropertySelectorSearchCo
layerSearch,
findRegion,
findDistrict,
loadPimsProperties,
]);

const handleOnAddressSelect = async (selectedItem: IGeocoderResponse) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getIn, useFormikContext } from 'formik';
import { Col, Row } from 'react-bootstrap';

import { RemoveButton } from '@/components/common/buttons';
Expand All @@ -18,6 +19,10 @@ export interface ISelectedPropertyRowProps {
export const SelectedPropertyRow: React.FunctionComponent<
React.PropsWithChildren<ISelectedPropertyRowProps>
> = ({ 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) {
Expand Down
10 changes: 4 additions & 6 deletions source/frontend/src/utils/mapPropertyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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(
Expand Down
Loading