mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
Formatting portfolio page
This commit is contained in:
parent
bcab685acb
commit
aabff33b82
5 changed files with 1424 additions and 12 deletions
2
src/app/db/migrations/0051_fat_callisto.sql
Normal file
2
src/app/db/migrations/0051_fat_callisto.sql
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE "portfolio" ADD COLUMN "labour_days" real;--> statement-breakpoint
|
||||
ALTER TABLE "recommendation" ADD COLUMN "labour_days" real;
|
||||
1372
src/app/db/migrations/meta/0051_snapshot.json
Normal file
1372
src/app/db/migrations/meta/0051_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -193,6 +193,7 @@ export type PropertyDetailsEpc = InferModel<
|
|||
// This type is used for the getProperties function in src/app/portfolio/[slug]/utils.ts
|
||||
export interface PropertyToRecommendation {
|
||||
estimatedCost?: number | null;
|
||||
sapPoints?: number | null;
|
||||
}
|
||||
|
||||
export interface PropertyWithRelations {
|
||||
|
|
@ -205,4 +206,6 @@ export interface PropertyWithRelations {
|
|||
target: { epc?: string | null; heatDemand?: number | null };
|
||||
recommendations: PropertyToRecommendation[];
|
||||
cost?: number | null;
|
||||
currentEpcRating: string | null;
|
||||
currentSapPoints: number | null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import { ArrowUpDown, MoreHorizontal } from "lucide-react";
|
|||
import StatusBadge from "@/app/components/StatusBadge";
|
||||
import { HomeIcon } from "@heroicons/react/20/solid";
|
||||
import { FunnelIcon } from "@heroicons/react/24/outline";
|
||||
import { formatNumber } from "@/app/utils";
|
||||
import { formatNumber, sapToEpc } from "@/app/utils";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { PortfolioStatus } from "@/app/db/schema/portfolio";
|
||||
import {
|
||||
|
|
@ -123,6 +123,49 @@ export const columns: ColumnDef<PropertyWithRelations>[] = [
|
|||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "currentEpc",
|
||||
header: () => <div className="flex justify-center">Current EPC Rating</div>,
|
||||
cell: ({ row }) => {
|
||||
return (
|
||||
<div className="text-gray-700 font-medium flex justify-center">
|
||||
{row.original.currentEpcRating || ""}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "targetEpc",
|
||||
header: () => <div className="flex justify-center">Expected EPC</div>,
|
||||
cell: ({ row }) => {
|
||||
const recommendations = row.original.recommendations;
|
||||
|
||||
const currentSapPoints = row.original.currentSapPoints;
|
||||
const expectedapPoints = recommendations.reduce(
|
||||
(acc: number, rec: PropertyToRecommendation) => {
|
||||
if (rec.sapPoints === null || rec.sapPoints === undefined) {
|
||||
return acc;
|
||||
}
|
||||
return acc + rec.sapPoints;
|
||||
},
|
||||
0
|
||||
);
|
||||
if (currentSapPoints === null || currentSapPoints === undefined) {
|
||||
return (
|
||||
<div className="text-gray-700 font-medium flex justify-center">
|
||||
{""}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
const expectedEpc = sapToEpc(currentSapPoints + expectedapPoints);
|
||||
|
||||
return (
|
||||
<div className="text-gray-700 font-medium flex justify-center">
|
||||
{expectedEpc || ""}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "cost",
|
||||
header: () => <div className="flex justify-center">Cost</div>,
|
||||
|
|
@ -153,17 +196,6 @@ export const columns: ColumnDef<PropertyWithRelations>[] = [
|
|||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "targetEpc",
|
||||
header: () => <div className="flex justify-center">Target EPC</div>,
|
||||
cell: ({ row }) => {
|
||||
return (
|
||||
<div className="text-gray-700 font-medium flex justify-center">
|
||||
{row.original.target?.epc || ""}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "actions",
|
||||
cell: ({ row }) => {
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ export async function getProperties(
|
|||
postcode: true,
|
||||
status: true,
|
||||
creationStatus: true,
|
||||
currentEpcRating: true,
|
||||
currentSapPoints: true,
|
||||
},
|
||||
where: eq(property.portfolioId, BigInt(portfolioId)),
|
||||
with: {
|
||||
|
|
@ -55,6 +57,7 @@ export async function getProperties(
|
|||
recommendations: {
|
||||
columns: {
|
||||
estimatedCost: true,
|
||||
sapPoints: true,
|
||||
},
|
||||
where: eq(recommendation.default, true),
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue