mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-30 12:55:02 +00:00
adding in general features table
This commit is contained in:
parent
7ecf3fd9d5
commit
13c2fb5ac1
3 changed files with 58 additions and 44 deletions
|
|
@ -16,48 +16,19 @@ import {
|
|||
TableRow,
|
||||
} from "@/app/shadcn_components/ui/table";
|
||||
|
||||
import { Badge } from "@/app/shadcn_components/ui/badge";
|
||||
import { Feature, Rating } from "@/app/db/schema/property";
|
||||
import { Feature, GeneralFeature } from "@/app/db/schema/property";
|
||||
|
||||
function RatingBadge({ rating }: { rating: Rating }) {
|
||||
const colourMap = {
|
||||
"Very good": "bg-green-500",
|
||||
Good: "bg-green-300",
|
||||
Poor: "bg-yellow-300",
|
||||
"Very poor": "bg-red-500",
|
||||
};
|
||||
const ratingConfig = colourMap[rating];
|
||||
return <Badge className={ratingConfig}>{rating}</Badge>;
|
||||
interface DataTableProps<T extends Feature | GeneralFeature> {
|
||||
columns: ColumnDef<T>[];
|
||||
data: T[];
|
||||
}
|
||||
|
||||
export const columns: ColumnDef<Feature>[] = [
|
||||
{
|
||||
accessorKey: "feature",
|
||||
header: "Feature",
|
||||
},
|
||||
{
|
||||
accessorKey: "description",
|
||||
header: "Description",
|
||||
},
|
||||
{
|
||||
accessorKey: "rating",
|
||||
header: "Rating",
|
||||
cell: ({ row }) => {
|
||||
return (
|
||||
<div className="">
|
||||
<RatingBadge rating={row.getValue("rating")} />
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
interface DataTableProps {
|
||||
data: Feature[];
|
||||
}
|
||||
|
||||
export default function FeatureTable({ data }: DataTableProps) {
|
||||
export default function FeatureTable<T extends Feature | GeneralFeature>({
|
||||
data,
|
||||
columns,
|
||||
}: DataTableProps<T>) {
|
||||
// Initialise the table
|
||||
|
||||
const table = useReactTable({
|
||||
data,
|
||||
columns,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export interface PropertyMeta {
|
|||
currentEpcRating: string;
|
||||
}
|
||||
|
||||
export type Rating = "Very good" | "Good" | "Poor" | "Very poor";
|
||||
export type Rating = "Very good" | "Good" | "Poor" | "Very poor" | "N/A";
|
||||
|
||||
export interface Feature {
|
||||
feature: string;
|
||||
|
|
@ -24,6 +24,11 @@ export interface Feature {
|
|||
rating: Rating;
|
||||
}
|
||||
|
||||
export interface GeneralFeature {
|
||||
feature: string;
|
||||
description: string | number;
|
||||
}
|
||||
|
||||
export interface ConditionReportData {
|
||||
id: number;
|
||||
lastUpdated: string;
|
||||
|
|
@ -35,6 +40,7 @@ export interface ConditionReportData {
|
|||
builtForm: string;
|
||||
totalFloorArea: number;
|
||||
tenure: string;
|
||||
features: Feature[];
|
||||
retrofitFeatures: Feature[];
|
||||
generalFeatures: GeneralFeature[];
|
||||
yearBuilt: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@ import EpcCard from "@/app/components/building-passport/EpcCard";
|
|||
import FeatureTable from "@/app/components/building-passport/FeatureTable";
|
||||
import { ConditionReportData, PropertyMeta } from "@/app/db/schema/property";
|
||||
import { formatDateTime } from "@/app/utils";
|
||||
import {
|
||||
generalColumns,
|
||||
retrofitColumns,
|
||||
} from "@/app/components/building-passport/FeatureTableColumns";
|
||||
|
||||
function AddressCard({ address }: { address: string }) {
|
||||
// In the future, we might want to use react-wrap-balancer for some of this text
|
||||
|
|
@ -116,7 +120,7 @@ export default async function PreAssessmentReport() {
|
|||
totalFloorArea: 60,
|
||||
tenure: "Rented (social)",
|
||||
yearBuilt: "1990",
|
||||
features: [
|
||||
retrofitFeatures: [
|
||||
{ feature: "Wall", description: "Cavity wall", rating: "Poor" },
|
||||
{
|
||||
feature: "Roof",
|
||||
|
|
@ -145,10 +149,37 @@ export default async function PreAssessmentReport() {
|
|||
description: "Suspended timber",
|
||||
rating: "Poor",
|
||||
},
|
||||
{
|
||||
feature: "Ventilation",
|
||||
description: "Natural",
|
||||
rating: "N/A",
|
||||
},
|
||||
{
|
||||
feature: "Solar Photo Voltaic",
|
||||
description: "Not present in the property",
|
||||
rating: "N/A",
|
||||
},
|
||||
{
|
||||
feature: "Solar Hot Water",
|
||||
description: "Heating is not solar powered",
|
||||
rating: "N/A",
|
||||
},
|
||||
{
|
||||
feature: "Wind Turbines",
|
||||
description: "No wind turbines present",
|
||||
rating: "N/A",
|
||||
},
|
||||
],
|
||||
generalFeatures: [
|
||||
{
|
||||
feature: "Floor Height",
|
||||
description: 2.4,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const features = conditionReportData.features;
|
||||
const retrofitFeatures = conditionReportData.retrofitFeatures;
|
||||
const generalFeatures = conditionReportData.generalFeatures;
|
||||
|
||||
return (
|
||||
<div className="leading-loose tracking-wider">
|
||||
|
|
@ -170,8 +201,14 @@ export default async function PreAssessmentReport() {
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex py-8 text-lg">Property Features</div>
|
||||
<FeatureTable data={features} />
|
||||
<div className="flex py-8 text-lg">General Features</div>
|
||||
<FeatureTable data={generalFeatures} columns={generalColumns} />
|
||||
{
|
||||
// Floor height, number of heated rooms, heat loss corridoor and heat loss corridor length, number of open fire places, number of extensions,
|
||||
// floor level if a flat, number of storeys if a flat, whether mains gas is available, energy tarigg,
|
||||
}
|
||||
<div className="flex py-8 text-lg">Retrotfit Property Features</div>
|
||||
<FeatureTable data={retrofitFeatures} columns={retrofitColumns} />
|
||||
<div className="flex py-8 text-lg">Heating Demand</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue