Merge pull request #116 from Hestia-Homes/eco-project-data

upgraded ui & changed reference of high_heat_retention_storage_heater
This commit is contained in:
KhalimCK 2025-11-04 20:59:47 +00:00 committed by GitHub
commit 4bee026bd3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 33 additions and 21 deletions

View file

@ -24,7 +24,7 @@ interface RecommendationContainerProps {
recommendations: Recommendation[];
propertyMeta: PropertyMeta;
planMeta: Plan;
funding: FundingPackageWithMeasures[]
funding: FundingPackageWithMeasures[];
}
const typeToCategoryMap: { [key in RecommendationType]?: RecommendationType } =
@ -56,19 +56,22 @@ export default function RecommendationContainer({
recommendations,
propertyMeta,
planMeta,
funding
funding,
}: RecommendationContainerProps) {
const categorizedRecommendations = recommendations.reduce((acc, curr) => {
const typeKey = curr.type as RecommendationType;
const category = typeToCategoryMap[typeKey] ?? typeKey;
const categorizedRecommendations = recommendations.reduce(
(acc, curr) => {
const typeKey = curr.type as RecommendationType;
const category = typeToCategoryMap[typeKey] ?? typeKey;
if (!acc[category]) {
acc[category] = [];
}
acc[category].push(curr);
if (!acc[category]) {
acc[category] = [];
}
acc[category].push(curr);
return acc;
}, {} as Record<RecommendationType, (typeof recommendations)[0][]>);
return acc;
},
{} as Record<RecommendationType, (typeof recommendations)[0][]>
);
const defaultWallsRecommendations =
categorizedRecommendations.wall_insulation?.find(
@ -319,8 +322,13 @@ export default function RecommendationContainer({
if (funding.length > 1) {
console.warn("Multiple funding packages found, using the first one.");
}
// Sum up project funding and uplift
const [totalFunding, setTotalFunding] = useState(funding[0]?.projectFunding || 0)
const [totalFunding, setTotalFunding] = useState(
funding[0]
? (funding[0].projectFunding ?? 0) + (funding[0].totalUplift ?? 0)
: 0
);
const currentEpcRating = propertyMeta.currentEpcRating;
const currentSapPoints = propertyMeta.currentSapPoints;

View file

@ -265,7 +265,7 @@ export const measuresDisplayLabels = {
suspended_floor_insulation: "Suspended Floor Insulation",
solid_floor_insulation: "Solid Floor Insulation",
boiler_upgrade: "Boiler Upgrade",
high_heat_retention_storage_heater: "High Heat Retention Storage Heater",
high_heat_retention_storage_heaters: "High Heat Retention Storage Heater",
air_source_heat_pump: "Air Source Heat Pump",
secondary_heating: "Secondary Heating",
solar_pv: "Solar PV",

View file

@ -140,7 +140,8 @@ export function ProjectProposal({ plans }: { plans: any[] }) {
<div>
<p className="text-xs text-gray-500 mb-1">Carbon</p>
<p className="text-md font-medium text-brandblue">
{((selectedData?.totalCarbon || 0) * 1000).toFixed(2)} kgCOe
{((selectedData?.totalCarbon || 0) * 1000).toFixed(0)}{" "}
<span className="text-sm text-gray-600 align-top">kgCOe</span>
</p>
</div>
<div>

View file

@ -1,18 +1,21 @@
import RecommendationContainer from "@/app/components/building-passport/RecommendationContainer";
import { getPropertyMeta, getRecommendations, getPlanMeta, getPlanFunding } from "../../utils";
import {
getPropertyMeta,
getRecommendations,
getPlanMeta,
getPlanFunding,
} from "../../utils";
export default async function Recommendations(
props: {
params: Promise<{ slug: string; propertyId: string; planId: string }>;
}
) {
export default async function Recommendations(props: {
params: Promise<{ slug: string; propertyId: string; planId: string }>;
}) {
const params = await props.params;
const propertyMeta = await getPropertyMeta(params.propertyId);
const recommendations = await getRecommendations(params.planId);
const planMeta = await getPlanMeta(params.planId);
const funding = await getPlanFunding(params.planId);
console.log(funding)
console.log("funding", funding);
return (
<div className="leading-loose tracking-wider">