diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/pre-assessment-report/page.tsx b/src/app/portfolio/[slug]/building-passport/[propertyId]/pre-assessment-report/page.tsx index d613578..46e52cb 100644 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/pre-assessment-report/page.tsx +++ b/src/app/portfolio/[slug]/building-passport/[propertyId]/pre-assessment-report/page.tsx @@ -10,7 +10,11 @@ import { generalColumns, retrofitColumns, } from "@/app/components/building-passport/FeatureTableColumns"; -import { getConditionReport, getPropertyMeta } from "../utils"; +import { + formatGeneralFeatures, + getConditionReport, + getPropertyMeta, +} from "../utils"; function AddressCard({ address }: { address: string | null }) { // In the future, we might want to use react-wrap-balancer for some of this text @@ -259,6 +263,11 @@ export default async function PreAssessmentReport({ // const generalFeatures = conditionReportData.generalFeatures; // const heatingDemand = conditionReportData.heatingDemand; + const generalFeatures = formatGeneralFeatures( + conditionReportData, + propertyMeta.propertyType + ); + return (
Pre Assessment Report
diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/utils.ts b/src/app/portfolio/[slug]/building-passport/[propertyId]/utils.ts index 7423d7a..931affe 100644 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/utils.ts +++ b/src/app/portfolio/[slug]/building-passport/[propertyId]/utils.ts @@ -36,3 +36,58 @@ export async function getConditionReport( return data; } + +export function formatGeneralFeatures( + conditionReportData: PropertyDetailsEpc, + propertyType: string +) { + // if a property is a flat/maisonette, we show heat loss coridoor information, otherwise we won't show it + + const flatOnlyFeatures = [ + { + feature: "Heat loss corridor", + description: Boolean(conditionReportData.heatLossCorridor) ? "Yes" : "No", + }, + { + feature: "Heat loss corridor length", + description: + conditionReportData.unheatedCorridorLength || "No heat loss corridor", + }, + { + feature: "Number of storeys", + description: conditionReportData.numberStoreys || "unknown", + }, + ]; + + const generealFeatures = [ + { + feature: "Floor Height", + description: conditionReportData.floorHeight || "unknown", + }, + { + feature: "Number of heated rooms", + description: conditionReportData.numberHeatedRooms || "unknown", + }, + { + feature: "Number of open fire places", + description: conditionReportData.numberOpenFireplaces || "unknown", + }, + { + feature: "Number of extensions", + description: conditionReportData.numberExtensions || "unknown", + }, + { + feature: "Mains gas", + description: conditionReportData.mainsGas || "unknown", + }, + { + feature: "Energy tariff", + description: conditionReportData.energyTariff, + }, + ...(propertyType === "Flat" || propertyType === "Maisonette" + ? flatOnlyFeatures + : []), + ]; + + return generealFeatures; +} diff --git a/src/types/epc.ts b/src/types/epc.ts index 93e3351..1e72e86 100644 --- a/src/types/epc.ts +++ b/src/types/epc.ts @@ -3,6 +3,8 @@ type SearchData = { rows: SearchResult[]; }; +type PropertyType = "Bungalow" | "House" | "Flat" | "Maisonette" | "Park Home"; + type SearchResult = { "low-energy-fixed-light-count": string; address: string; @@ -22,7 +24,7 @@ type SearchResult = { address3: string; "mainheatcont-description": string; "sheating-energy-eff": string; - "property-type": string; + "property-type": PropertyType; "local-authority-label": string; "fixed-lighting-outlets-count": string; "energy-tariff": string; @@ -105,4 +107,11 @@ interface EpcDataProps { type EpcRating = SearchResult["current-energy-rating"]; type EpcKey = keyof SearchResult; -export type { SearchData, SearchResult, EpcDataProps, EpcRating, EpcKey }; +export type { + SearchData, + SearchResult, + EpcDataProps, + EpcRating, + EpcKey, + PropertyType, +};