Skip to content

Commit

Permalink
Merge 6b3b914 into eb9b358
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak authored Jul 19, 2024
2 parents eb9b358 + 6b3b914 commit 8960a80
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
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');

0 comments on commit 8960a80

Please sign in to comment.