From 1fbaeae85a76a514e4c9e6bcc60ae0748e503724 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Thu, 21 Dec 2023 15:57:37 +0000 Subject: [PATCH] Added windows recommendations to the front end --- .../building-passport/RecommendationCard.tsx | 2 ++ .../building-passport/RecommendationContainer.tsx | 12 ++++++++++++ .../building-passport/RecommendationModal.tsx | 12 +++++++++++- src/app/db/schema/recommendations.ts | 1 + src/types/recommendations.ts | 1 + 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/app/components/building-passport/RecommendationCard.tsx b/src/app/components/building-passport/RecommendationCard.tsx index da9aeb9..32ac4f1 100644 --- a/src/app/components/building-passport/RecommendationCard.tsx +++ b/src/app/components/building-passport/RecommendationCard.tsx @@ -29,6 +29,8 @@ const TitleMap = { solid_floor_insulation: "Solid Floor Insulation", suspended_floor_insulation: "Suspended Floor Insulation", exposed_floor_insulation: "Exposed Floor Insulation", + // Windows + windows_glazing: "Window Glazing", // Default options when no recommendation is selected wall_insulation: "Wall Insulation", floor_insulation: "Floor Insulation", diff --git a/src/app/components/building-passport/RecommendationContainer.tsx b/src/app/components/building-passport/RecommendationContainer.tsx index db26845..a6e9339 100644 --- a/src/app/components/building-passport/RecommendationContainer.tsx +++ b/src/app/components/building-passport/RecommendationContainer.tsx @@ -33,6 +33,7 @@ const typeToCategoryMap: { [key in RecommendationType]?: RecommendationType } = suspended_floor_insulation: "floor_insulation", solid_floor_insulation: "floor_insulation", exposed_floor_insulation: "floor_insulation", + windows_glazing: "windows_glazing", }; const emptyImpactState = { @@ -90,6 +91,11 @@ export default function RecommendationContainer({ (rec: Recommendation) => rec.default ) || emptyImpactState; + const defaultWindowsRecommendations = + categorizedRecommendations.windows_glazing?.find( + (rec: Recommendation) => rec.default + ) || emptyImpactState; + const [costMap, setCostMap] = useState({ wall_insulation: defaultWallsRecommendations?.estimatedCost || 0, floor_insulation: defaultFloorRecommendations?.estimatedCost || 0, @@ -98,6 +104,7 @@ export default function RecommendationContainer({ defaultVentiliationRecommendations?.estimatedCost || 0, sealing_open_fireplace: defaultFireplaceRecommendations?.estimatedCost || 0, low_energy_lighting: defaultLightingRecommendations?.estimatedCost || 0, + windows_glazing: defaultWindowsRecommendations?.estimatedCost || 0, }); const [sapMap, setSapMap] = useState({ @@ -107,6 +114,7 @@ export default function RecommendationContainer({ mechanical_ventilation: defaultVentiliationRecommendations.sapPoints || 0, sealing_open_fireplace: defaultFireplaceRecommendations.sapPoints || 0, low_energy_lighting: defaultLightingRecommendations.sapPoints || 0, + windows_glazing: defaultWindowsRecommendations.sapPoints || 0, }); const [labourDaysMap, setLabourDaysMap] = useState({ @@ -116,6 +124,7 @@ export default function RecommendationContainer({ mechanical_ventilation: defaultVentiliationRecommendations.labourDays || 0, sealing_open_fireplace: defaultFireplaceRecommendations.labourDays || 0, low_energy_lighting: defaultLightingRecommendations.labourDays || 0, + windows_glazing: defaultWindowsRecommendations.labourDays || 0, }); const [co2SavingsMap, setCo2SavingsMap] = useState({ @@ -128,6 +137,7 @@ export default function RecommendationContainer({ defaultFireplaceRecommendations.co2EquivalentSavings || 0, low_energy_lighting: defaultLightingRecommendations.co2EquivalentSavings || 0, + windows_glazing: defaultWindowsRecommendations.co2EquivalentSavings || 0, }); const [energyCostSavingsMap, setEnergyCostSavingsMap] = @@ -141,6 +151,7 @@ export default function RecommendationContainer({ defaultFireplaceRecommendations.energyCostSavings || 0, low_energy_lighting: defaultLightingRecommendations.energyCostSavings || 0, + windows_glazing: defaultWindowsRecommendations.energyCostSavings || 0, }); const [heatDemandMap, setHeatDemandMap] = useState({ @@ -150,6 +161,7 @@ export default function RecommendationContainer({ mechanical_ventilation: defaultVentiliationRecommendations.heatDemand || 0, sealing_open_fireplace: defaultFireplaceRecommendations.heatDemand || 0, low_energy_lighting: defaultLightingRecommendations.heatDemand || 0, + windows_glazing: defaultWindowsRecommendations.heatDemand || 0, }); const [totalEstimatedCost, setTotalEstimatedCost] = useState( diff --git a/src/app/components/building-passport/RecommendationModal.tsx b/src/app/components/building-passport/RecommendationModal.tsx index 9ff7356..cde156f 100644 --- a/src/app/components/building-passport/RecommendationModal.tsx +++ b/src/app/components/building-passport/RecommendationModal.tsx @@ -36,6 +36,16 @@ interface RecommendationModalProps { setTotalHeatDemandSavings: Dispatch>; } +const TitleMap = { + floor_insulation: "Floor Insulation", + roof_insulation: "Roof Insulation", + wall_insulation: "Wall Insulation", + mechanical_ventilation: "Ventilation", + sealing_open_fireplace: "Sealing Fireplaces", + low_energy_lighting: "Low Energy Lighting", + windows_glazing: "Window Glazing", +}; + export default function RecommendationModal({ title, isOpen = false, @@ -197,7 +207,7 @@ export default function RecommendationModal({ as="h3" className="text-lg font-medium leading-6 text-brandblue mb-3" > - {title} + {TitleMap[title as keyof typeof TitleMap]}