From f3793ad020a11ab16d40eddd416ac5b7898fe4e0 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Wed, 31 May 2023 09:51:49 +0100 Subject: [PATCH] Added epc target popup on summary box in plan --- src/app/components/plan/PlanPart.tsx | 4 +- .../[slug]/property/[lmkKey]/plan/page.tsx | 45 ++++++++++++++----- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/app/components/plan/PlanPart.tsx b/src/app/components/plan/PlanPart.tsx index 4890e42..75f5f76 100644 --- a/src/app/components/plan/PlanPart.tsx +++ b/src/app/components/plan/PlanPart.tsx @@ -22,7 +22,7 @@ export default function PlanPart({ { label: "option 2", value: "option 2" }, { label: "option 3", value: "option 3" }, { label: "option 4", value: "option 4" }, - { label: "option 5", value: "option 5" }, + { label: "option5", value: "option 5" }, ]; const [selectedOption, setSelectedOption] = useState(options[0].value); @@ -37,7 +37,7 @@ export default function PlanPart({

{title}

{selectedOption}
-

Cost: {cost}

+

Cost: £{cost}

CO2 Emissions: {co2Emissions}

diff --git a/src/app/portfolio/[slug]/property/[lmkKey]/plan/page.tsx b/src/app/portfolio/[slug]/property/[lmkKey]/plan/page.tsx index 9d1adf9..89eb386 100644 --- a/src/app/portfolio/[slug]/property/[lmkKey]/plan/page.tsx +++ b/src/app/portfolio/[slug]/property/[lmkKey]/plan/page.tsx @@ -1,12 +1,13 @@ "use client"; -import { SearchData } from "@/types/epc"; +import { EpcRating, SearchData } from "@/types/epc"; import { useQuery } from "@tanstack/react-query"; import { useRouter } from "next/navigation"; import { fetchData } from "../utils"; import { useState } from "react"; import { PencilSquareIcon } from "@heroicons/react/24/outline"; import PlanPart from "@/app/components/plan/PlanPart"; +import EditEpctargetModal from "@/app/components/property/EditEpcTargetModal"; export default function Plan({ params, @@ -20,12 +21,8 @@ export default function Plan({ const portfolioId = params.slug; const lmkKey = params.lmkKey; const postcode = searchParams.postcode; - const targetEpcRating = searchParams.targetEpcRating ?? "C"; - - const [budget, setBudget] = useState("Not set"); - const [totalCost, setTotalCost] = useState("Not set"); - const [installTime, setInstallTime] = useState("Not set"); + // Temp config for the demo const partsConfig = [ { part: "Roof", cost: 1000, co2Emissions: 50, workHours: 20 }, { part: "Walls", cost: 1000, co2Emissions: 50, workHours: 20 }, @@ -57,6 +54,19 @@ export default function Plan({ }, ]; + const totalWorkHours = partsConfig.reduce( + (sum, part) => sum + part.workHours, + 0 + ); + + const [budget, setBudget] = useState("Not set"); + const [totalCost, setTotalCost] = useState("Not set"); + const [installTime, setInstallTime] = useState(totalWorkHours); + const [isEditModalOpen, setIsEditModalOpen] = useState(false); + const [targetEpcRating, setTargetEpcRating] = useState( + (searchParams.targetEpcRating as EpcRating) ?? "C" + ); + if (postcode === undefined) { router.push(`/portfolio/${portfolioId}/error`); } @@ -101,15 +111,19 @@ export default function Plan({

Summary

    -
  • +
  • setIsEditModalOpen(true)} + className="px-2 mb-2 flex items-center cursor-pointer hover:bg-brandblue hover:rounded-md transition-colors duration-200" + > Target EPC: {targetEpcRating}
  • -
  • Total cost: {totalCost}
  • -
  • Budget: {budget}
  • -
  • Installation Time: {installTime}
  • - {/* flex items-center text-brandmidblue hover:text-brandblue transition-colors duration-200 cursor-pointer */} -
  • +
  • Total cost: {totalCost}
  • +
  • Budget: {budget}
  • +
  • + Installation Time: {installTime} hours +
  • +
  • Edit Property Details
  • @@ -118,6 +132,13 @@ export default function Plan({
+ ); }