From c01f5bee40a634012e8f13e1629725abd80f1920 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Wed, 15 Apr 2026 09:50:17 +0000 Subject: [PATCH] added notify for user when we've remodelled --- .../api/property-meta/[propertyId]/route.ts | 1 + src/app/db/schema/property.ts | 1 + .../assessment/EpcInfoTooltip.tsx | 67 ---------------- .../[propertyId]/assessment/page.tsx | 80 ++----------------- .../building-passport/[propertyId]/page.tsx | 77 ++---------------- 5 files changed, 14 insertions(+), 212 deletions(-) delete mode 100644 src/app/portfolio/[slug]/building-passport/[propertyId]/assessment/EpcInfoTooltip.tsx diff --git a/src/app/api/property-meta/[propertyId]/route.ts b/src/app/api/property-meta/[propertyId]/route.ts index 9bda547..81f47ae 100644 --- a/src/app/api/property-meta/[propertyId]/route.ts +++ b/src/app/api/property-meta/[propertyId]/route.ts @@ -26,6 +26,7 @@ export async function GET(request: NextRequest, props: { params: Promise<{ prope tenure: true, currentEpcRating: true, currentSapPoints: true, + originalSapPoints: true, updatedAt: true, currentValuation: true, }, diff --git a/src/app/db/schema/property.ts b/src/app/db/schema/property.ts index 3d2dd56..58e956f 100644 --- a/src/app/db/schema/property.ts +++ b/src/app/db/schema/property.ts @@ -34,6 +34,7 @@ export interface PropertyMeta { tenure: string; currentEpcRating: string; currentSapPoints: number; + originalSapPoints: number | null; updatedAt: string; currentValuation: number | null; detailsEpc: { diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/assessment/EpcInfoTooltip.tsx b/src/app/portfolio/[slug]/building-passport/[propertyId]/assessment/EpcInfoTooltip.tsx deleted file mode 100644 index bdc7d17..0000000 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/assessment/EpcInfoTooltip.tsx +++ /dev/null @@ -1,67 +0,0 @@ -"use client"; - -import { QuestionMarkCircleIcon } from "@heroicons/react/24/outline"; -import { - Tooltip, - TooltipContent, - TooltipProvider, - TooltipTrigger, -} from "@/app/shadcn_components/ui/tooltip"; - -const EPC_BANDS = [ - { band: "A", range: "92–100", color: "#117d58", desc: "Exceptional, near-zero energy bills, usually new-builds or eco-homes." }, - { band: "B", range: "81–91", color: "#2da55c", desc: "Very efficient, often featuring solar panels, high-grade insulation, and modern heating." }, - { band: "C", range: "69–80", color: "#8dbd40", desc: "Good, above-average efficiency; common target for retrofitting existing homes." }, - { band: "D", range: "55–68", color: "#f7cd14", desc: "Average, the typical rating for many homes in the UK." }, - { band: "E", range: "39–54", color: "#f3a96a", desc: "Below average, likely requires better insulation and boiler upgrades." }, - { band: "F", range: "21–38", color: "#ef8026", desc: "Poor, high energy costs and lower energy performance." }, - { band: "G", range: "1–20", color: "#e41e3b", desc: "Very poor, least efficient, high energy costs." }, -]; - -export function EpcInfoTooltip() { - return ( - - - - - - -
-

EPC Rating Bands

-

Based on the SAP score (1–100)

-
-
- {EPC_BANDS.map(({ band, range, color, desc }) => ( -
- - {band} - -
-

{range}

-

{desc}

-
-
- ))} -
-
-

- SAP score — Standard Assessment Procedure. A government-approved method for rating the energy performance of homes on a scale of 1 to 100. -

-
-
-
-
- ); -} diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/assessment/page.tsx b/src/app/portfolio/[slug]/building-passport/[propertyId]/assessment/page.tsx index 78d7b26..a2123cb 100644 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/assessment/page.tsx +++ b/src/app/portfolio/[slug]/building-passport/[propertyId]/assessment/page.tsx @@ -18,36 +18,10 @@ import { import { getSolarData, getSolarScenarioData } from "../solar-analysis/utils"; import PropertyMapWrapper from "../solar-analysis/PropertyMapWrapper"; import SolarSimulationWrapper from "../solar-analysis/SolarSimulationWrapper"; -import { EpcInfoTooltip } from "./EpcInfoTooltip"; +import { CurrentEfficiencyCard } from "@/app/components/building-passport/CurrentEfficiencyCard"; // ── Helpers ──────────────────────────────────────────────────────────────────── -function getEpcHex(letter: string | null | undefined): string { - switch (letter?.toUpperCase()) { - case "A": return "#117d58"; - case "B": return "#2da55c"; - case "C": return "#8dbd40"; - case "D": return "#f7cd14"; - case "E": return "#f3a96a"; - case "F": return "#ef8026"; - case "G": return "#e41e3b"; - default: return "#9ca3af"; - } -} - -function getEpcDescription(letter: string | null | undefined): string { - switch (letter?.toUpperCase()) { - case "A": - case "B": return "This property is performing at or above modern energy standards."; - case "C": return "This property meets modern energy performance benchmarks."; - case "D": return "This property is performing slightly below modern energy standards."; - case "E": return "This property is performing below modern energy standards."; - case "F": - case "G": return "This property is performing significantly below modern energy standards."; - default: return "Energy performance data is not yet available for this property."; - } -} - function getDirectionLabel(az: number): { label: string; short: string } { const norm = ((az % 360) + 360) % 360; if (norm >= 337.5 || norm < 22.5) return { short: "N", label: "North" }; @@ -211,10 +185,6 @@ export default async function PreAssessmentReport(props: { const rawSolar = await getSolarData(Number(propertyMeta.uprn)); const solarData = rawSolar ?? null; - const epcLetter = propertyMeta.currentEpcRating ?? null; - const sapScore = propertyMeta.currentSapPoints ?? 0; - const epcHex = getEpcHex(epcLetter); - // Solar derived values const sp = solarData?.googleApiResponse?.solarPotential ?? null; const solarScenarioData = solarData ? await getSolarScenarioData(String(solarData.id)) : null; @@ -265,49 +235,11 @@ export default async function PreAssessmentReport(props: {
{/* EPC Hero — matches overview page style */} -
-
-
-
-

- Current Efficiency State -

- -
-
- - {epcLetter ?? "—"} - - - / {sapScore || "—"} - -
-

- {getEpcDescription(epcLetter)} -

-
-
-
-
-
-
- Very Inefficient - Very Efficient -
-
-
+ {/* Right column: 3 metric cards + general features grid */}
diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/page.tsx b/src/app/portfolio/[slug]/building-passport/[propertyId]/page.tsx index ee422a3..1035edf 100644 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/page.tsx +++ b/src/app/portfolio/[slug]/building-passport/[propertyId]/page.tsx @@ -15,6 +15,7 @@ import { getInstalledMeasuresByUprn, } from "./utils"; import { HeritageTooltip } from "./HeritageTooltip"; +import { CurrentEfficiencyCard } from "@/app/components/building-passport/CurrentEfficiencyCard"; export const revalidate = 1; @@ -25,33 +26,6 @@ function formatGbp(value: number | null | undefined): string { return `£${Math.round(value).toLocaleString("en-GB")}`; } -/** Map EPC letter to its hex color from the project's palette */ -function getEpcHex(letter: string | null | undefined): string { - switch (letter?.toUpperCase()) { - case "A": return "#117d58"; - case "B": return "#2da55c"; - case "C": return "#8dbd40"; - case "D": return "#f7cd14"; - case "E": return "#f3a96a"; - case "F": return "#ef8026"; - case "G": return "#e41e3b"; - default: return "#9ca3af"; - } -} - -function getEpcDescription(letter: string | null | undefined): string { - switch (letter?.toUpperCase()) { - case "A": - case "B": return "This property is performing at or above modern energy standards."; - case "C": return "This property meets modern energy performance benchmarks."; - case "D": return "This property is performing slightly below modern energy standards."; - case "E": return "This property is performing below modern energy standards."; - case "F": - case "G": return "This property is performing significantly below modern energy standards."; - default: return "Energy performance data is not yet available for this property."; - } -} - // ── Sub-components ──────────────────────────────────────────────────────────── function SectionHeading({ icon, label }: { icon: React.ReactNode; label: string }) { @@ -102,10 +76,6 @@ export default async function BuildingPassportHome(props: { (conditionReport.hotWaterEnergyCostCurrent ?? 0) + (conditionReport.lightingEnergyCostCurrent ?? 0); - const epcLetter = propertyMeta.currentEpcRating ?? null; - const sapScore = propertyMeta.currentSapPoints ?? 0; - const epcHex = getEpcHex(epcLetter); - return (
@@ -113,46 +83,11 @@ export default async function BuildingPassportHome(props: {
{/* EPC Hero */} -
-
-
-

- Current Efficiency State -

-
- - {epcLetter ?? "—"} - - - / {sapScore || "—"} - -
-

- {getEpcDescription(epcLetter)} -

-
-
-
-
-
-
- Very Inefficient - Very Efficient -
-
-
+ {/* Energy Stats + Heritage Status */}