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

wip: set property.attachment where property.type is a granular "residential.dwelling.house" type #3440

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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 @@ -76,6 +76,7 @@ export default function PickOSAddress(props: PickOSAddressProps): FCReturn {
uprn: selectedAddress.UPRN.padStart(12, "0"),
usrn: selectedAddress.USRN, // padStart(8, "0") will break /roads API request
blpu_code: selectedAddress.BLPU_STATE_CODE,
classification_code: selectedAddress.CLASSIFICATION_CODE,
latitude: selectedAddress.LAT,
longitude: selectedAddress.LNG,
organisation: selectedAddress.ORGANISATION || null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ export const FETCH_BLPU_CODES = gql`
}
`;

// For automations, these CLASSIFICATION_CODES set `property.type` = `residential.dwelling.house` ONLY
// and the fourth segment is extracted to it's own variable `property.attachment`
export const ATTACHMENT_CLASSIFICATION_CODES = [
{
code: "RD02",
value: "detached",
},
{
code: "RD03",
value: "semiDetached",
},
{
code: "RD04",
value: "terrace",
},
];

type Props = PublicProps<FindProperty>;

const AddressLoadingWrap = styled(Box)(({ theme }) => ({
Expand Down Expand Up @@ -146,6 +163,18 @@ function Component(props: Props) {
newPassportData["property.type"] = [address.planx_value];
}

if (
address?.classification_code &&
ATTACHMENT_CLASSIFICATION_CODES.map((c) => c.code).includes(
address.classification_code,
)
) {
const attachmentValue = ATTACHMENT_CLASSIFICATION_CODES.find(
(c) => c.code === address.classification_code,
)?.value;
newPassportData["property.attachment"] = [attachmentValue];
}

if (localAuthorityDistricts) {
newPassportData["property.localAuthorityDistrict"] =
localAuthorityDistricts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export interface SiteAddress extends MinimumSiteAddress {
uprn?: string;
usrn?: string;
blpu_code?: string;
classification_code?: string;
organisation?: string | null;
sao?: string | null;
pao?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- UPDATE "public"."blpu_codes"
-- SET value = 'residential.dwelling.house'
-- WHERE code IN ('RD02', 'RD03', 'RD04');
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
UPDATE "public"."blpu_codes"
SET value = 'residential.dwelling.house'
WHERE code IN ('RD02', 'RD03', 'RD04');
Loading