diff --git a/src/app/components/building-passport/Toolbar.tsx b/src/app/components/building-passport/Toolbar.tsx index b0759e4..8d74d52 100644 --- a/src/app/components/building-passport/Toolbar.tsx +++ b/src/app/components/building-passport/Toolbar.tsx @@ -1,5 +1,6 @@ "use client"; +import { useState } from "react"; import { Cog6ToothIcon, NewspaperIcon, @@ -8,6 +9,7 @@ import { SunIcon, CircleStackIcon, HeartIcon, + CalendarDaysIcon, } from "@heroicons/react/24/outline"; import { NavigationMenu, @@ -15,12 +17,17 @@ import { NavigationMenuList, NavigationMenuLink, } from "@/app/shadcn_components/ui/navigation-menu"; +import { Button } from "@/app/shadcn_components/ui/button"; import { cva } from "class-variance-authority"; import { getUploadedFile } from "@/app/db/surveyDB/schema/surveyDB"; +import BookSurveyModal from "@/app/portfolio/[slug]/components/BookSurveyModal"; +import BookingSuccessToast from "@/app/portfolio/[slug]/components/BookingSuccessToast"; +import { PropertyMeta } from "@/app/db/schema/property"; interface ToolbarProps { propertyId: string; portfolioId: string; + propertyMeta: PropertyMeta decentHomes: getUploadedFile; } @@ -50,7 +57,6 @@ const navigationMenuTriggerStyle = cva( "disabled:opacity-50", "data-[active]:bg-accent/50", "data-[state=open]:bg-gray-200", - // "text-gray-900", ].join(" ") ); @@ -58,8 +64,12 @@ const navigationMenuTriggerStyle = cva( export function Toolbar({ propertyId, portfolioId, + propertyMeta, decentHomes, }: ToolbarProps) { + const [openModal, setOpenModal] = useState(false); + const [showToast, setShowToast] = useState(false); + function handleClickSettings() { console.log("Settings were clicked, implement me"); } @@ -115,33 +125,67 @@ export function Toolbar({ ); return ( - - - - Summary - + <> +
+ {/* Left side: navigation */} + + + + Summary + - - {preAssessmentReportButton} - {/* We only show decent homes button if decent homes is not an empty object */} - {Object.keys(decentHomes).length > 0 && - decentHomes.uprn && - decentHomesButton} - {solarAnalysisButton} - {recommendationsButton} - {documentsButton} + + {preAssessmentReportButton} + {Object.keys(decentHomes).length > 0 && + decentHomes.uprn && + decentHomesButton} + {solarAnalysisButton} + {recommendationsButton} + {documentsButton} - - - Settings - - - + + + Settings + + + + + {/* ✅ Right side: Book a Survey button */} +
+ +
+
+ + {/* ✅ Modal */} + {openModal && ( + setShowToast(true)} + /> + )} + + {/* ✅ Toast */} + setShowToast(false)} + message="Survey Booked Successfully!" + subtext="Your Survey Request is with Domna and will be in contact with you shortly. 🎉" + /> + ); } diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/BuildingPassportHomeClient.tsx b/src/app/portfolio/[slug]/building-passport/[propertyId]/BuildingPassportHomeClient.tsx index 9ab29b7..6e4f6a9 100644 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/BuildingPassportHomeClient.tsx +++ b/src/app/portfolio/[slug]/building-passport/[propertyId]/BuildingPassportHomeClient.tsx @@ -24,10 +24,6 @@ export default function BuildingPassportHomeClient({ propertyMeta, portfolioId, }: BuildingPassportHomeClientProps) { - const [openModal, setOpenModal] = useState(false); - const [showToast, setShowToast] = useState(false); - console.log(portfolioId) - console.log(propertyMeta) return (
@@ -92,29 +88,6 @@ export default function BuildingPassportHomeClient({ Book a Survey
- - {/* ✅ Modal for booking a survey */} - {openModal && ( - { - setOpenModal(false); - setShowToast(true); - }} - /> - )} - - {/* ✅ Success Toast */} - setShowToast(false)} - message="Survey Booked Successfully!" - subtext="Your survey request has been sent to Domna. We'll contact you shortly. 🎉" - /> ); } diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/layout.tsx b/src/app/portfolio/[slug]/building-passport/[propertyId]/layout.tsx index 5da4b86..11358e3 100644 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/layout.tsx +++ b/src/app/portfolio/[slug]/building-passport/[propertyId]/layout.tsx @@ -60,6 +60,7 @@ export default async function DashboardLayout(props: { diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/page.tsx b/src/app/portfolio/[slug]/building-passport/[propertyId]/page.tsx index 326b673..047090d 100644 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/page.tsx +++ b/src/app/portfolio/[slug]/building-passport/[propertyId]/page.tsx @@ -1,20 +1,70 @@ +import EpcCard from "@/app/components/building-passport/EpcCard"; +import { formatDateTime } from "@/app/utils"; +import { + HomeIcon, + BuildingOfficeIcon, + CalendarIcon, + HomeModernIcon, + ClockIcon, + UserGroupIcon, +} from "@heroicons/react/24/solid"; import { getPropertyMeta } from "./utils"; -import BuildingPassportHomeClient from "./BuildingPassportHomeClient"; export const revalidate = 1; -export default async function BuildingPassportHome({ - params, -}: { - params: { slug: string; propertyId: string }; -}) { +export default async function BuildingPassportHome( + props: { + params: Promise<{ slug: string; propertyId: string }>; + } +) { + const params = await props.params; + // This is a server component and because we make the exact same request in the layout, + // the response is cached so we just gain access to the data const propertyMeta = await getPropertyMeta(params.propertyId); - // ✅ pass both property data and the portfolio slug (from the URL) return ( - +
+
+ +
+
Your property
+
+ +
Building Passport Created At:
+
{formatDateTime(propertyMeta.createdAt)}
+
+
+ +
Property Type:
+
{propertyMeta.propertyType}
+
+
+ +
Built Form:
+
{propertyMeta.builtForm}
+
+
+ +
Year Built:
+
{propertyMeta.yearBuilt}
+
+
+ +
Tenure:
+
{propertyMeta.tenure}
+
+
+ +
Number of Habitable Rooms:
+
{propertyMeta.numberOfRooms}
+
+
+
+
); } \ No newline at end of file