mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
implemented formatting retrofit features
This commit is contained in:
parent
3d3bc6a31a
commit
85da1008b9
3 changed files with 108 additions and 2 deletions
|
|
@ -12,6 +12,7 @@ import {
|
|||
} from "@/app/components/building-passport/FeatureTableColumns";
|
||||
import {
|
||||
formatGeneralFeatures,
|
||||
formatRetrofitFeatures,
|
||||
getConditionReport,
|
||||
getPropertyMeta,
|
||||
} from "../utils";
|
||||
|
|
@ -268,6 +269,8 @@ export default async function PreAssessmentReport({
|
|||
propertyMeta.propertyType
|
||||
);
|
||||
|
||||
const retrofitFeatures = formatRetrofitFeatures(conditionReportData);
|
||||
|
||||
return (
|
||||
<div className="leading-loose tracking-wider">
|
||||
<div className="flex py-8 text-lg">Pre Assessment Report</div>
|
||||
|
|
@ -291,9 +294,9 @@ export default async function PreAssessmentReport({
|
|||
</div>
|
||||
<div className="flex py-8 text-lg">General Features</div>
|
||||
<FeatureTable data={generalFeatures} columns={generalColumns} />
|
||||
{/* <div className="flex py-8 text-lg">Retrotfit Property Features</div>
|
||||
<div className="flex py-8 text-lg">Existing Property Features</div>
|
||||
<FeatureTable data={retrofitFeatures} columns={retrofitColumns} />
|
||||
<div className="flex py-8 text-lg">Heating Demand</div>
|
||||
{/* <div className="flex py-8 text-lg">Heating Demand</div>
|
||||
<FeatureTable data={heatingDemand} columns={generalColumns} /> */}
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import { db } from "@/app/db/db";
|
||||
import {
|
||||
Feature,
|
||||
GeneralFeature,
|
||||
PropertyDetailsEpc,
|
||||
PropertyMeta,
|
||||
propertyDetailsEpc,
|
||||
} from "@/app/db/schema/property";
|
||||
import { getRating } from "@/app/utils";
|
||||
import { eq } from "drizzle-orm";
|
||||
|
||||
export async function getPropertyMeta(
|
||||
|
|
@ -92,3 +94,82 @@ export function formatGeneralFeatures(
|
|||
|
||||
return generealFeatures;
|
||||
}
|
||||
|
||||
export function formatRetrofitFeatures(
|
||||
conditionReportData: PropertyDetailsEpc
|
||||
): Feature[] {
|
||||
// Helper function to convert rating number to string
|
||||
|
||||
const retrofitFeatures: Feature[] = [
|
||||
{
|
||||
feature: "Wall",
|
||||
description: conditionReportData.walls || "N/A",
|
||||
rating: getRating(conditionReportData.wallsRating),
|
||||
},
|
||||
{
|
||||
feature: "Roof",
|
||||
description: conditionReportData.roof || "N/A",
|
||||
rating: getRating(conditionReportData.roofRating),
|
||||
},
|
||||
{
|
||||
feature: "Windows",
|
||||
description: conditionReportData.windows || "N/A",
|
||||
rating: getRating(conditionReportData.windowsRating),
|
||||
},
|
||||
{
|
||||
feature: "Heating",
|
||||
description: conditionReportData.heating || "N/A",
|
||||
rating: getRating(conditionReportData.heatingRating),
|
||||
},
|
||||
{
|
||||
feature: "Heating Control",
|
||||
description: conditionReportData.heatingControls || "N/A",
|
||||
rating: getRating(conditionReportData.heatingControlsRating),
|
||||
},
|
||||
{
|
||||
feature: "Hot Water",
|
||||
description: conditionReportData.hotWater || "N/A",
|
||||
rating: getRating(conditionReportData.hotWaterRating),
|
||||
},
|
||||
{
|
||||
feature: "Lighting",
|
||||
description: conditionReportData.lighting || "N/A",
|
||||
rating: getRating(conditionReportData.lightingRating),
|
||||
},
|
||||
{
|
||||
feature: "Floor",
|
||||
description: conditionReportData.floor || "N/A",
|
||||
rating: getRating(conditionReportData.floorRating),
|
||||
},
|
||||
{
|
||||
feature: "Ventilation",
|
||||
description: conditionReportData.ventilation || "N/A",
|
||||
rating: "N/A",
|
||||
},
|
||||
{
|
||||
feature: "Solar Photo Voltaic",
|
||||
description:
|
||||
conditionReportData.solarPv != null
|
||||
? "Present in the property"
|
||||
: "Not present in the property",
|
||||
rating: "N/A",
|
||||
},
|
||||
{
|
||||
feature: "Solar Hot Water",
|
||||
description: conditionReportData.solarHotWater
|
||||
? "Heating is solar powered"
|
||||
: "Heating is not solar powered",
|
||||
rating: "N/A",
|
||||
},
|
||||
{
|
||||
feature: "Wind Turbines",
|
||||
description:
|
||||
conditionReportData.windTurbine != null
|
||||
? `${conditionReportData.windTurbine} wind turbines present`
|
||||
: "No wind turbines present",
|
||||
rating: "N/A",
|
||||
},
|
||||
];
|
||||
|
||||
return retrofitFeatures;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,25 @@
|
|||
import { Rating } from "./db/schema/property";
|
||||
|
||||
export const getRating = (rating: number | null): Rating => {
|
||||
if (rating == null) {
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
if (![1, 2, 3, 4, 5].includes(rating)) {
|
||||
throw new Error("Rating should be between 1 and 5.");
|
||||
}
|
||||
|
||||
const ratingMap: { [key in 1 | 2 | 3 | 4 | 5]: string } = {
|
||||
1: "Very poor",
|
||||
2: "Poor",
|
||||
3: "Average",
|
||||
4: "Good",
|
||||
5: "Very good",
|
||||
};
|
||||
|
||||
return ratingMap[rating as 1 | 2 | 3 | 4 | 5]; // You can assert that rating is one of these values since you've already checked it
|
||||
};
|
||||
|
||||
export const serializeBigInt = (_: any, value: any): string | any => {
|
||||
// Simple utility function to convert BigInts to strings with JSON.stringify
|
||||
return typeof value === "bigint" ? value.toString() : value;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue