From c64969bd078967fec9f59b514c8e94b27237e7c3 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Wed, 16 Aug 2023 16:28:44 +0100 Subject: [PATCH] implemented layout of plan card --- .../components/building-passport/EpcCard.tsx | 21 +++++- .../[propertyId]/recommendations/page.tsx | 74 ++++++++++++++++--- src/app/utils.ts | 2 +- 3 files changed, 85 insertions(+), 12 deletions(-) diff --git a/src/app/components/building-passport/EpcCard.tsx b/src/app/components/building-passport/EpcCard.tsx index ef0f0aa..086b85f 100644 --- a/src/app/components/building-passport/EpcCard.tsx +++ b/src/app/components/building-passport/EpcCard.tsx @@ -1,18 +1,35 @@ export default function EpcCard({ epcRating, fullMargin = true, + expected = false, }: { epcRating: string; fullMargin: boolean; + expected?: boolean; }) { let marginClass = ""; if (fullMargin) { marginClass = "mx-auto"; } + let title; + let bgStyling; + if (expected) { + title = "Expected Energy Rating"; + bgStyling = "bg-green-600"; + } else { + title = "Energy Rating"; + bgStyling = "bg-brandblue"; + } + return ( -
-
Energy Rating
+
+
{title}
{epcRating}
); diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/recommendations/page.tsx b/src/app/portfolio/[slug]/building-passport/[propertyId]/recommendations/page.tsx index 5a53dd5..4249c99 100644 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/recommendations/page.tsx +++ b/src/app/portfolio/[slug]/building-passport/[propertyId]/recommendations/page.tsx @@ -2,7 +2,63 @@ import { Recommendation } from "@/app/db/schema/recommendations"; import { PropertyMeta } from "@/app/db/schema/property"; import RecommendationContainer from "@/app/components/building-passport/RecommendationContainer"; import { getPlans, getPropertyMeta } from "../utils"; -import { sapToEpc } from "@/app/utils"; +import { formatDateTime, formatNumber, sapToEpc } from "@/app/utils"; +import EpcCard from "@/app/components/building-passport/EpcCard"; +import { ChevronRight } from "lucide-react"; +import { + Card, + CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, +} from "@/app/shadcn_components/ui/card"; +import { Button } from "@/app/shadcn_components/ui/button"; + +function PlanCard({ + expectedEpcRating, + createdAt, + totalEstimatedCost, + totalSapPoints, +}: { + expectedEpcRating: string; + createdAt: Date; + totalEstimatedCost: number; + totalSapPoints: number; +}) { + return ( + +
+ +
+
+ + + + + + Created: {formatDateTime(createdAt)} + +
+ Total cost: + £{formatNumber(totalEstimatedCost)} +
+
+ Total SAP points: + {totalSapPoints} +
+
+
+
+ ); +} export default async function Recommendations({ params, @@ -18,7 +74,7 @@ export default async function Recommendations({
Retrofit Plans
-
+
{plans.map((plan, index) => { const totalEstimatedCost = plan.planRecommendations.reduce( (acc, rec) => acc + rec.recommendation.estimatedCost, @@ -38,13 +94,13 @@ export default async function Recommendations({ const expectedEpcRating = sapToEpc(expectedSapPoints); return ( -
-
Created At: {plan.createdAt.toISOString()}
-
Is Default: {plan.isDefault ? "Yes" : "No"}
-
Total Estimated Cost: £{totalEstimatedCost}
-
Total SAP Points: {totalSapPoints}
-
Expected EP Rating: {expectedEpcRating}
-
+ ); })}
diff --git a/src/app/utils.ts b/src/app/utils.ts index 35c5c64..8a099ef 100644 --- a/src/app/utils.ts +++ b/src/app/utils.ts @@ -47,7 +47,7 @@ export function sapToEpc(sapPoints: number): string { } } -export function formatDateTime(dateTimeString: string): string { +export function formatDateTime(dateTimeString: string | Date): string { // Create a new Date object const dateTime = new Date(dateTimeString);