diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/decent-homes/page.tsx b/src/app/portfolio/[slug]/building-passport/[propertyId]/decent-homes/page.tsx index 125cb36..4354842 100644 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/decent-homes/page.tsx +++ b/src/app/portfolio/[slug]/building-passport/[propertyId]/decent-homes/page.tsx @@ -237,7 +237,11 @@ function CriterionContent({ function ReplacementsContent({ items, }: { - items: { sub_variable: string; expiry_date: string | null }[]; + items: { + sub_variable: string; + expiry_date: string | null; + install_date: string | null; + }[]; }) { const today = new Date(); const groups: Record< @@ -245,6 +249,7 @@ function ReplacementsContent({ { sub_variable: string; expiry: Date; + install: Date; remaining: string; overdue: boolean; }[] @@ -256,8 +261,9 @@ function ReplacementsContent({ }; items.forEach((item) => { - if (!item.expiry_date) return; + if (!item.expiry_date || !item.install_date) return; const expiry = new Date(item.expiry_date); + const install = new Date(item.install_date); const diffMs = expiry.getTime() - today.getTime(); const diffMonths = diffMs / (1000 * 60 * 60 * 24 * 30); @@ -276,6 +282,7 @@ function ReplacementsContent({ const entry = { sub_variable: SUB_ITEMS_TEXT[item.sub_variable] ?? item.sub_variable, expiry, + install, remaining, overdue, }; @@ -351,9 +358,14 @@ function ReplacementsContent({
{comp.remaining} - - {comp.expiry.toLocaleDateString("en-GB")} - +
+ + {`Installed: ${comp.install.toLocaleDateString("en-GB")}`} + + + {`Expired: ${comp.expiry.toLocaleDateString("en-GB")}`} + +
))} @@ -385,6 +397,7 @@ function DecentHomesSummary({ sub_variable: string; result: string; expiry_date?: string | null; + install_date?: string | null; }[]; }) { const overallPass = decentHomes.decent_homes === "pass"; @@ -407,8 +420,11 @@ function DecentHomesSummary({ D: [], }; - const replacements: { sub_variable: string; expiry_date: string | null }[] = - []; + const replacements: { + sub_variable: string; + expiry_date: string | null; + install_date: string | null; + }[] = []; decentHomesMeta.forEach((item) => { if (criteriaGroups[item.criteria]) { @@ -421,6 +437,7 @@ function DecentHomesSummary({ replacements.push({ sub_variable: item.sub_variable, expiry_date: item.expiry_date, + install_date: item.install_date ?? null, }); } }); @@ -428,8 +445,7 @@ function DecentHomesSummary({ const soonCount = replacements.filter((r) => { if (!r.expiry_date) return false; const expiry = new Date(r.expiry_date); - const diffMs = expiry.getTime() - new Date().getTime(); - return diffMs < 1000 * 60 * 60 * 24 * 365; + return expiry.getTime() < Date.now(); // strictly overdue }).length; return ( @@ -463,7 +479,7 @@ function DecentHomesSummary({ Replacements