From 3b9602b293cc98ac7b4deb81d9913464af038730 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Wed, 16 Aug 2023 17:23:52 +0100 Subject: [PATCH] Setting up plans page --- .../components/building-passport/EpcCard.tsx | 2 +- .../RecommendationContainer.tsx | 2 +- .../building-passport/RecommendationModal.tsx | 2 +- .../components/building-passport/Toolbar.tsx | 8 +- .../pre-assessment-report/page.tsx | 53 +++-- .../[propertyId]/recommendations/page.tsx | 182 ------------------ .../[propertyId]/recommendations/utils.tsx | 10 - .../building-passport/[propertyId]/utils.ts | 4 - 8 files changed, 30 insertions(+), 233 deletions(-) delete mode 100644 src/app/portfolio/[slug]/building-passport/[propertyId]/recommendations/page.tsx delete mode 100644 src/app/portfolio/[slug]/building-passport/[propertyId]/recommendations/utils.tsx diff --git a/src/app/components/building-passport/EpcCard.tsx b/src/app/components/building-passport/EpcCard.tsx index 086b85fe..4925a0b1 100644 --- a/src/app/components/building-passport/EpcCard.tsx +++ b/src/app/components/building-passport/EpcCard.tsx @@ -25,7 +25,7 @@ export default function EpcCard({ return (
diff --git a/src/app/components/building-passport/RecommendationContainer.tsx b/src/app/components/building-passport/RecommendationContainer.tsx index d4ee30fb..ae34bb98 100644 --- a/src/app/components/building-passport/RecommendationContainer.tsx +++ b/src/app/components/building-passport/RecommendationContainer.tsx @@ -10,7 +10,7 @@ import { Separator } from "@/app/shadcn_components/ui/separator"; import { PropertyMeta } from "@/app/db/schema/property"; import { sapToEpc } from "@/app/utils"; import { useState } from "react"; -import { sumRecommendationMetricMap } from "@/app/portfolio/[slug]/building-passport/[propertyId]/recommendations/utils"; +import { sumRecommendationMetricMap } from "@/app/portfolio/[slug]/building-passport/[propertyId]/plans/utils"; import { RecommendationMetricMap } from "@/types/recommendations"; import RecommendationEpcSummaryCard from "./RecommendationEpcSummaryCard"; diff --git a/src/app/components/building-passport/RecommendationModal.tsx b/src/app/components/building-passport/RecommendationModal.tsx index 5081c15e..08e3971c 100644 --- a/src/app/components/building-passport/RecommendationModal.tsx +++ b/src/app/components/building-passport/RecommendationModal.tsx @@ -4,7 +4,7 @@ import { Dispatch, Fragment, SetStateAction, useState } from "react"; import { Dialog, Transition } from "@headlessui/react"; import RecommendationTable from "@/app/components/building-passport/RecommendationTable"; import { RecommendationMetricMap } from "@/types/recommendations"; -import { sumRecommendationMetricMap } from "@/app/portfolio/[slug]/building-passport/[propertyId]/recommendations/utils"; +import { sumRecommendationMetricMap } from "@/app/portfolio/[slug]/building-passport/[propertyId]/plans/utils"; import uvalueColumns from "./RecommendationTableColumns"; import { sapToEpc } from "@/app/utils"; diff --git a/src/app/components/building-passport/Toolbar.tsx b/src/app/components/building-passport/Toolbar.tsx index ced6cf91..655c86d2 100644 --- a/src/app/components/building-passport/Toolbar.tsx +++ b/src/app/components/building-passport/Toolbar.tsx @@ -46,10 +46,10 @@ export function Toolbar({ propertyId, portfolioId }: ToolbarProps) { const recommendationsButton = ( - Retrofit Recommendations + Retrofit Plans ); @@ -66,13 +66,13 @@ export function Toolbar({ propertyId, portfolioId }: ToolbarProps) { {preAssessmentReportButton} {recommendationsButton} - Plan optimiser - + */} +
{address}
); @@ -35,6 +35,9 @@ interface PropertyDetailsCardProps { }; } +const rowTitleStyle = "text-gray-100 align-top pb-3"; +const rowValueStyle = "text-gray-100 text-end pr-8 pt-1 align-top pb-3"; + function PropertyDetailsCard({ conditionReportData, propertyMeta, @@ -45,33 +48,29 @@ function PropertyDetailsCard({ .join(" "); return ( -
-
+
+
- +
- - + + - - + + - - + - - + @@ -81,26 +80,20 @@ function PropertyDetailsCard({
Year built: - {propertyMeta.yearBuilt} - Year built:{propertyMeta.yearBuilt}
Property Type: - {propertyText} - Property Type:{propertyText}
Total floor area: + Total floor area: {`${conditionReportData.totalFloorArea} m`} 2
In conservation area: + In conservation area: {propertyDetailsSpatial.inConservationArea}
- - + + - - + + - - + + - - + diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/recommendations/page.tsx b/src/app/portfolio/[slug]/building-passport/[propertyId]/recommendations/page.tsx deleted file mode 100644 index 4249c990..00000000 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/recommendations/page.tsx +++ /dev/null @@ -1,182 +0,0 @@ -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 { 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, -}: { - params: { slug: string; propertyId: string }; -}) { - const propertyMeta = await getPropertyMeta(params.propertyId); - const plans = await getPlans(params.propertyId); - console.log("PLANS", plans); - console.log(plans[0].planRecommendations); - - return ( -
-
Retrofit Plans
- -
- {plans.map((plan, index) => { - const totalEstimatedCost = plan.planRecommendations.reduce( - (acc, rec) => acc + rec.recommendation.estimatedCost, - 0 - ); - const totalSapPoints = plan.planRecommendations.reduce( - (acc, rec) => acc + rec.recommendation.sapPoints, - 0 - ); - - // Placeholder while we return 999 for all sap points - const expectedSapPoints = Math.min( - propertyMeta.currentSapPoints + totalSapPoints, - 100 - ); - - const expectedEpcRating = sapToEpc(expectedSapPoints); - - return ( - - ); - })} -
-
- ); - - // const recommendations: Recommendation = { - // Walls: [ - // { - // id: 1, - // type: "internal_wall_insulation", - // description: "140mm Mineral Wool internal wall insulation", - // estimatedCost: 9_450, - // default: true, - // newUValue: 0.29, - // sapPoints: 4, - // }, - // { - // id: 2, - // type: "internal_wall_insulation", - // description: "30mm Vacuum Insulation Panels wall insulation", - // estimatedCost: 10_135, - // default: false, - // newUValue: 0.28, - // sapPoints: 12, - // }, - // { - // id: 3, - // type: "internal_external_wall_insulation", - // description: - // "80mm Mineral Wool External Wall Insulation and 30mm rigid insulation internal wall insulation", - // estimatedCost: 13_450, - // default: false, - // newUValue: 0.25, - // sapPoints: 14, - // }, - // ], - // Ventilation: [ - // { - // id: 4, - // type: "mechanical_ventilation", - // description: "Two decentralised mechanical ventilation units", - // estimatedCost: 750, - // default: true, - // sapPoints: -2, - // }, - // ], - // Floor: [ - // { - // id: 5, - // type: "suspended_floor_insulation", - // description: "70mm Rigid insulation foam boards with floor screed", - // estimatedCost: 3_450, - // default: true, - // newUValue: 0.24, - // sapPoints: 7, - // }, - // { - // id: 5, - // type: "suspended_floor_insulation", - // description: "90mm Rigid insulation foam boards with floor screed", - // estimatedCost: 4_120, - // default: true, - // newUValue: 0.24, - // sapPoints: 7, - // }, - // ], - // }; - - // return ( - //
- //
Recommendations
- // - //
- // ); -} diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/recommendations/utils.tsx b/src/app/portfolio/[slug]/building-passport/[propertyId]/recommendations/utils.tsx deleted file mode 100644 index d3f77e42..00000000 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/recommendations/utils.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { RecommendationMetricMap } from "@/types/recommendations"; - -export function sumRecommendationMetricMap( - obj: RecommendationMetricMap -): number { - // In the recommendations section of the building passport we have the cost map which - // contains the costs of the recommendations. We need to sum these costs to display - // the total cost of the recommendations - return Object.values(obj).reduce((sum, current) => sum + current, 0); -} diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/utils.ts b/src/app/portfolio/[slug]/building-passport/[propertyId]/utils.ts index 75e0110d..67064c8c 100644 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/utils.ts +++ b/src/app/portfolio/[slug]/building-passport/[propertyId]/utils.ts @@ -12,10 +12,6 @@ import { plan, Plan } from "@/app/db/schema/recommendations"; import { getRating } from "@/app/utils"; import { eq } from "drizzle-orm"; -// type PlanRelation = Plan & { -// planRecommendations: PlanRecommendations; -// }; - type PlanRelation = Plan & { planRecommendations: { recommendation: { estimatedCost: number; sapPoints: number };
Local Authority: - {propertyMeta.localAuthority} - Local Authority:{propertyMeta.localAuthority}
Constituency: - {propertyMeta.constituency} - Constituency:{propertyMeta.constituency}
Tenure - {propertyMeta.tenure} - Tenure{propertyMeta.tenure}
Number of rooms: + Number of rooms: {propertyMeta.numberOfRooms || "unkown"}