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-8413 | Fixed lease warning not showing #4038

Merged
merged 1 commit into from
May 23, 2024
Merged
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 @@ -15,7 +15,7 @@ import { useProperties } from '@/hooks/repositories/useProperties';
import useDeepCompareEffect from '@/hooks/util/useDeepCompareEffect';
import useDeepCompareMemo from '@/hooks/util/useDeepCompareMemo';
import { ApiGen_Concepts_PropertyView } from '@/models/api/generated/ApiGen_Concepts_PropertyView';
import { isValidId } from '@/utils';
import { exists, isValidId, isValidString } from '@/utils';

import { FormLeaseProperty, LeaseFormModel } from '../../models';
import SelectedPropertyHeaderRow from './selectedPropertyList/SelectedPropertyHeaderRow';
Expand Down Expand Up @@ -113,28 +113,25 @@ export const LeasePropertySelector: React.FunctionComponent<LeasePropertySelecto
: undefined;

// Retrieve the pims id of the property if it exists
if (isValidId(formProperty.property?.apiId)) {
formProperty.property!.address = bcaSummary?.address
if (exists(formProperty.property) && !isValidId(formProperty.property.apiId)) {
needsWarning = true;

formProperty.property.address = bcaSummary?.address
? AddressForm.fromBcaAddress(bcaSummary?.address)
: undefined;

const hasPinOrPid =
formProperty.property!.pid !== undefined || formProperty.property!.pin !== undefined;
if (hasPinOrPid) {
if (
isValidString(formProperty.property.pid) ||
isValidString(formProperty.property.pin)
) {
const result = await searchProperty(property);
if (result !== undefined && result.length > 0) {
formProperty.property!.apiId = result[0].id;
formProperty.property.apiId = result[0].id;
}
}
}

newFormProperties.push(formProperty);

if (isValidId(formProperty.property?.apiId)) {
needsWarning = needsWarning || true;
} else {
needsWarning = needsWarning || false;
}
});
}, Promise.resolve());

Expand Down
Loading