diff --git a/src/app/api/property-meta/[propertyId]/route.ts b/src/app/api/property-meta/[propertyId]/route.ts index 7adffe2..8951eba 100644 --- a/src/app/api/property-meta/[propertyId]/route.ts +++ b/src/app/api/property-meta/[propertyId]/route.ts @@ -27,6 +27,7 @@ export async function GET( tenure: true, currentEpcRating: true, currentSapPoints: true, + updatedAt: true, }, where: eq(property.id, BigInt(propertyId)), }); diff --git a/src/app/db/schema/property.ts b/src/app/db/schema/property.ts index d6c3cb8..a99a2e9 100644 --- a/src/app/db/schema/property.ts +++ b/src/app/db/schema/property.ts @@ -30,6 +30,7 @@ export interface PropertyMeta { tenure: string; currentEpcRating: string; currentSapPoints: number; + updatedAt: string; } export type Rating = "Very good" | "Good" | "Poor" | "Very poor" | "N/A"; 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 8fa3457..d613578 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 @@ -1,6 +1,10 @@ import EpcCard from "@/app/components/building-passport/EpcCard"; import FeatureTable from "@/app/components/building-passport/FeatureTable"; -import { ConditionReportData, PropertyMeta } from "@/app/db/schema/property"; +import { + ConditionReportData, + PropertyDetailsEpc, + PropertyMeta, +} from "@/app/db/schema/property"; import { formatDateTime } from "@/app/utils"; import { generalColumns, @@ -8,7 +12,7 @@ import { } from "@/app/components/building-passport/FeatureTableColumns"; import { getConditionReport, getPropertyMeta } from "../utils"; -function AddressCard({ address }: { address: string }) { +function AddressCard({ address }: { address: string | null }) { // In the future, we might want to use react-wrap-balancer for some of this text return (
@@ -18,14 +22,22 @@ function AddressCard({ address }: { address: string }) { } interface PropertyDetailsCardProps { - conditionReportData: ConditionReportData; + conditionReportData: PropertyDetailsEpc; propertyMeta: PropertyMeta; + propertyDetailsSpatial: { + inConservationArea: string; + }; } function PropertyDetailsCard({ conditionReportData, propertyMeta, + propertyDetailsSpatial, }: PropertyDetailsCardProps) { + const propertyText = [propertyMeta.builtForm, propertyMeta.propertyType] + .filter(Boolean) + .join(" "); + return (
@@ -40,7 +52,9 @@ function PropertyDetailsCard({ Property Type: - {`${conditionReportData.builtForm} ${conditionReportData.propertyType}`} + + {propertyText} + Total floor area: @@ -52,7 +66,7 @@ function PropertyDetailsCard({ In conservation area: - {conditionReportData.inConservationArea} + {propertyDetailsSpatial.inConservationArea} @@ -81,7 +95,7 @@ function PropertyDetailsCard({ Number of rooms: - {propertyMeta.numberOfRooms} + {propertyMeta.numberOfRooms || "unkown"} @@ -99,6 +113,9 @@ export default async function PreAssessmentReport({ // TODO: Add main fuel! const propertyMeta = await getPropertyMeta(params.propertyId); const conditionReportData = await getConditionReport(params.propertyId); + const propertyDetailsSpatial = { + inConservationArea: "No", + }; console.log("DATA!!"); console.log(conditionReportData); @@ -242,19 +259,16 @@ export default async function PreAssessmentReport({ // const generalFeatures = conditionReportData.generalFeatures; // const heatingDemand = conditionReportData.heatingDemand; - console.log("I GOT?"); - console.log(conditionReportData); - return (
Pre Assessment Report
- Last updated: {formatDateTime(conditionReportData.lastUpdated)} + Last updated: {formatDateTime(propertyMeta.updatedAt)}
@@ -262,12 +276,13 @@ export default async function PreAssessmentReport({
General Features
- {/* -
Retrotfit Property Features
+ + {/*
Retrotfit Property Features
Heating Demand
*/} diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/utils.ts b/src/app/portfolio/[slug]/building-passport/[propertyId]/utils.ts index 2c39cc0..7423d7a 100644 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/utils.ts +++ b/src/app/portfolio/[slug]/building-passport/[propertyId]/utils.ts @@ -11,9 +11,11 @@ export async function getPropertyMeta( ): Promise { const url = process.env.URL + `/api/property-meta/${propertyId}`; + // Note, for the moment, we don't cache the data const response = await fetch(url, { method: "GET", headers: { "Content-Type": "application/json" }, + next: { revalidate: 60 }, }); if (!response.ok) { throw new Error("Network response was not ok");