changed adjusted heat demand to kwh savings

This commit is contained in:
Khalim Conn-Kowlessar 2024-07-09 23:21:03 +01:00
parent 8418be48a7
commit 67a23759c9
8 changed files with 1718 additions and 52 deletions

View file

@ -52,13 +52,13 @@ export function EnergyEfficiencyImpactCard({
interface SecondaryEnergyEfficiencyImpactCardProps {
TotalCo2Savings: number;
totalEnergyCostSavings: number;
totalHeatDemandSavings: number;
totalKwhSavings: number;
}
export function SecondaryEnergyEfficiencyImpactCard({
TotalCo2Savings,
totalEnergyCostSavings,
totalHeatDemandSavings,
totalKwhSavings,
}: SecondaryEnergyEfficiencyImpactCardProps) {
return (
<div>
@ -77,9 +77,7 @@ export function SecondaryEnergyEfficiencyImpactCard({
<tr>
<td className="font-medium pl-4 py-2">Energy Savings</td>
<td className="pr-2">
{totalHeatDemandSavings.toFixed(0) + "kWh"}
</td>
<td className="pr-2">{totalKwhSavings.toFixed(0) + "kWh"}</td>
</tr>
<tr>

View file

@ -67,9 +67,9 @@ type RecommendationCardProps = {
setEnergyCostSavingsMap: Dispatch<SetStateAction<RecommendationMetricMap>>;
energyCostSavingsMap: RecommendationMetricMap;
setTotalEnergyCostSavings: Dispatch<SetStateAction<number>>;
setHeatDemandMap: Dispatch<SetStateAction<RecommendationMetricMap>>;
heatDemandMap: RecommendationMetricMap;
setTotalHeatDemandSavings: Dispatch<SetStateAction<number>>;
setKwhSavingsMap: Dispatch<SetStateAction<RecommendationMetricMap>>;
kwhSavingsMap: RecommendationMetricMap;
setTotalKwhSavings: Dispatch<SetStateAction<number>>;
};
export default function RecommendationCard({
@ -92,9 +92,9 @@ export default function RecommendationCard({
setEnergyCostSavingsMap,
energyCostSavingsMap,
setTotalEnergyCostSavings,
setHeatDemandMap,
heatDemandMap,
setTotalHeatDemandSavings,
setKwhSavingsMap,
kwhSavingsMap,
setTotalKwhSavings,
}: RecommendationCardProps) {
const defaultComponent = recommendationData.find(
(rec: Recommendation) => rec.default
@ -220,10 +220,10 @@ export default function RecommendationCard({
setEnergyCostSavingsMap={setEnergyCostSavingsMap}
energyCostSavingsMap={energyCostSavingsMap}
setTotalEnergyCostSavings={setTotalEnergyCostSavings}
// Heat Demand
setHeatDemandMap={setHeatDemandMap}
heatDemandMap={heatDemandMap}
setTotalHeatDemandSavings={setTotalHeatDemandSavings}
// kWh Savings
setKwhSavingsMap={setKwhSavingsMap}
kwhSavingsMap={kwhSavingsMap}
setTotalKwhSavings={setTotalKwhSavings}
/>
</div>
);

View file

@ -43,7 +43,7 @@ const emptyImpactState = {
labourDays: 0,
co2EquivalentSavings: 0,
energyCostSavings: 0,
adjustedHeatDemand: 0,
kwhSavings: 0,
};
export default function RecommendationContainer({
@ -215,24 +215,20 @@ export default function RecommendationContainer({
defaultSecondaryHeatingRecommendations.energyCostSavings || 0,
});
const [heatDemandMap, setHeatDemandMap] = useState<RecommendationMetricMap>({
wall_insulation: defaultWallsRecommendations.adjustedHeatDemand || 0,
floor_insulation: defaultFloorRecommendations.adjustedHeatDemand || 0,
roof_insulation: defaultRoofRecommendations.adjustedHeatDemand || 0,
mechanical_ventilation:
defaultVentiliationRecommendations.adjustedHeatDemand || 0,
sealing_open_fireplace:
defaultFireplaceRecommendations.adjustedHeatDemand || 0,
low_energy_lighting: defaultLightingRecommendations.adjustedHeatDemand || 0,
windows_glazing: defaultWindowsRecommendations.adjustedHeatDemand || 0,
solar_pv: defaultSolarRecommendations.adjustedHeatDemand || 0,
heating: defaultHeatingRecommendations.adjustedHeatDemand || 0,
const [kwhSavingsMap, setKwhSavingsMap] = useState<RecommendationMetricMap>({
wall_insulation: defaultWallsRecommendations.kwhSavings || 0,
floor_insulation: defaultFloorRecommendations.kwhSavings || 0,
roof_insulation: defaultRoofRecommendations.kwhSavings || 0,
mechanical_ventilation: defaultVentiliationRecommendations.kwhSavings || 0,
sealing_open_fireplace: defaultFireplaceRecommendations.kwhSavings || 0,
low_energy_lighting: defaultLightingRecommendations.kwhSavings || 0,
windows_glazing: defaultWindowsRecommendations.kwhSavings || 0,
solar_pv: defaultSolarRecommendations.kwhSavings || 0,
heating: defaultHeatingRecommendations.kwhSavings || 0,
hot_water_tank_insulation:
defaultHotWaterTankRecommendations.adjustedHeatDemand || 0,
heating_control:
defaultHeatingControlRecommendations.adjustedHeatDemand || 0,
secondary_heating:
defaultSecondaryHeatingRecommendations.adjustedHeatDemand || 0,
defaultHotWaterTankRecommendations.kwhSavings || 0,
heating_control: defaultHeatingControlRecommendations.kwhSavings || 0,
secondary_heating: defaultSecondaryHeatingRecommendations.kwhSavings || 0,
});
const [totalEstimatedCost, setTotalEstimatedCost] = useState(
@ -255,8 +251,8 @@ export default function RecommendationContainer({
sumRecommendationMetricMap(energyCostSavingsMap)
);
const [totalHeatDemandSavings, setTotalHeatDemandSavings] = useState(
sumRecommendationMetricMap(heatDemandMap)
const [totalKwhSavings, setTotalKwhSavings] = useState(
sumRecommendationMetricMap(kwhSavingsMap)
);
const currentEpcRating = propertyMeta.currentEpcRating;
@ -286,7 +282,7 @@ export default function RecommendationContainer({
<SecondaryEnergyEfficiencyImpactCard
TotalCo2Savings={totalCo2Savings}
totalEnergyCostSavings={totalEnergyCostSavings}
totalHeatDemandSavings={totalHeatDemandSavings}
totalKwhSavings={totalKwhSavings}
/>
</div>
@ -323,10 +319,10 @@ export default function RecommendationContainer({
setEnergyCostSavingsMap={setEnergyCostSavingsMap}
energyCostSavingsMap={energyCostSavingsMap}
setTotalEnergyCostSavings={setTotalEnergyCostSavings}
// Heat Demand
setHeatDemandMap={setHeatDemandMap}
heatDemandMap={heatDemandMap}
setTotalHeatDemandSavings={setTotalHeatDemandSavings}
// kwh Savings
setKwhSavingsMap={setKwhSavingsMap}
kwhSavingsMap={kwhSavingsMap}
setTotalKwhSavings={setTotalKwhSavings}
/>
);
}

View file

@ -31,9 +31,9 @@ interface RecommendationModalProps {
setEnergyCostSavingsMap: Dispatch<SetStateAction<RecommendationMetricMap>>;
energyCostSavingsMap: RecommendationMetricMap;
setTotalEnergyCostSavings: Dispatch<SetStateAction<number>>;
setHeatDemandMap: Dispatch<SetStateAction<RecommendationMetricMap>>;
heatDemandMap: RecommendationMetricMap;
setTotalHeatDemandSavings: Dispatch<SetStateAction<number>>;
setKwhSavingsMap: Dispatch<SetStateAction<RecommendationMetricMap>>;
kwhSavingsMap: RecommendationMetricMap;
setTotalKwhSavings: Dispatch<SetStateAction<number>>;
}
const TitleMap = {
@ -70,9 +70,9 @@ export default function RecommendationModal({
setEnergyCostSavingsMap,
energyCostSavingsMap,
setTotalEnergyCostSavings,
setHeatDemandMap,
heatDemandMap,
setTotalHeatDemandSavings,
setKwhSavingsMap,
kwhSavingsMap,
setTotalKwhSavings,
}: RecommendationModalProps) {
const [saveButtonDisabled, setSaveButtonDisabled] = useState(true);
@ -165,15 +165,15 @@ export default function RecommendationModal({
);
// Update the heat demand savings map
const newHeatDemandMap = {
...heatDemandMap,
[title]: recommendationData[newIndex]?.adjustedHeatDemand || 0,
const newKwhSavingsMap = {
...kwhSavingsMap,
[title]: recommendationData[newIndex]?.kwhSavings || 0,
};
setHeatDemandMap(newHeatDemandMap);
setKwhSavingsMap(newKwhSavingsMap);
// update the heat demand savings sum
setTotalHeatDemandSavings(sumRecommendationMetricMap(newHeatDemandMap));
setTotalKwhSavings(sumRecommendationMetricMap(newKwhSavingsMap));
}
return (

View file

@ -0,0 +1 @@
ALTER TABLE "recommendation" RENAME COLUMN "adjusted_heat_demand" TO "kwh_savings";

File diff suppressed because it is too large Load diff

View file

@ -491,6 +491,13 @@
"when": 1719414126722,
"tag": "0069_rich_klaw",
"breakpoints": true
},
{
"idx": 70,
"version": "5",
"when": 1720563097899,
"tag": "0070_sweet_riptide",
"breakpoints": true
}
]
}

View file

@ -29,7 +29,7 @@ export const recommendation = pgTable("recommendation", {
newUValue: real("new_u_value"),
sapPoints: real("sap_points"),
heatDemand: real("heat_demand"),
adjustedHeatDemand: real("adjusted_heat_demand"),
kwhSavings: real("kwh_savings"),
co2EquivalentSavings: real("co2_equivalent_savings"),
energySavings: real("energy_savings"),
energyCostSavings: real("energy_cost_savings"),