diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/BuildingPassportHomeClient.tsx b/src/app/portfolio/[slug]/building-passport/[propertyId]/BuildingPassportHomeClient.tsx new file mode 100644 index 00000000..9ab29b71 --- /dev/null +++ b/src/app/portfolio/[slug]/building-passport/[propertyId]/BuildingPassportHomeClient.tsx @@ -0,0 +1,120 @@ +"use client"; + +import { useState } from "react"; +import EpcCard from "@/app/components/building-passport/EpcCard"; +import { Button } from "@/app/shadcn_components/ui/button"; +import { formatDateTime } from "@/app/utils"; +import { + CalendarIcon, + HomeIcon, + BuildingOfficeIcon, + ClockIcon, + UserGroupIcon, + HomeModernIcon, +} from "@heroicons/react/24/solid"; +import BookSurveyModal from "../../components/BookSurveyModal"; +import BookingSuccessToast from "../../components/BookingSuccessToast"; + +interface BuildingPassportHomeClientProps { + propertyMeta: any; + portfolioId: string; // ✅ from URL (slug) +} + +export default function BuildingPassportHomeClient({ + propertyMeta, + portfolioId, +}: BuildingPassportHomeClientProps) { + const [openModal, setOpenModal] = useState(false); + const [showToast, setShowToast] = useState(false); + console.log(portfolioId) + console.log(propertyMeta) + + return ( +
+ {/* EPC Card + Property Info */} +
+ {/* EPC Rating Card */} + + + {/* Property Info Card */} +
+
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}
+
+
+
+ + {/* ✅ "Book a Survey" Button */} +
+ +
+ + {/* ✅ 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]/page.tsx b/src/app/portfolio/[slug]/building-passport/[propertyId]/page.tsx index ccb05275..326b6739 100644 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/page.tsx +++ b/src/app/portfolio/[slug]/building-passport/[propertyId]/page.tsx @@ -1,70 +1,20 @@ -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( - 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 +export default async function BuildingPassportHome({ + params, +}: { + params: { slug: string; propertyId: string }; +}) { 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 diff --git a/src/app/portfolio/[slug]/components/BookSurveyModal.tsx b/src/app/portfolio/[slug]/components/BookSurveyModal.tsx index bd599ce8..39f6651f 100644 --- a/src/app/portfolio/[slug]/components/BookSurveyModal.tsx +++ b/src/app/portfolio/[slug]/components/BookSurveyModal.tsx @@ -17,7 +17,7 @@ interface BookSurveyModalProps { open: boolean; onOpenChange: (open: boolean) => void; propertyId: bigint; - portfolioId: bigint; + portfolioId: string; address: string; onSuccess?: () => void; // ✅ fix: properly declare optional callback } @@ -41,7 +41,7 @@ export default function BookSurveyModal({ pipelineId: "2400089278", dealStageId: "3288115388", propertyId: propertyId.toString(), - portfolioId: portfolioId.toString(), + portfolioId: portfolioId, }), }); diff --git a/src/app/portfolio/[slug]/components/propertyTableColumns.tsx b/src/app/portfolio/[slug]/components/propertyTableColumns.tsx index 52307c13..c65a7743 100644 --- a/src/app/portfolio/[slug]/components/propertyTableColumns.tsx +++ b/src/app/portfolio/[slug]/components/propertyTableColumns.tsx @@ -21,9 +21,6 @@ import { PropertyToRecommendation, PropertyWithRelations, } from "@/app/db/schema/property"; -import BookSurveyModal from "./BookSurveyModal"; -import BookingSuccessToast from "./BookingSuccessToast"; -import { useState } from "react"; interface DataTableColumnHeaderProps @@ -218,10 +215,7 @@ export const columns: ColumnDef[] = [ { id: "actions", cell: ({ row }) => { - const [openModal, setOpenModal] = useState(false); - const [showToast, setShowToast] = useState(false); const property = row.original; - const address = String(row.getValue("address")); const propertyId = property.id; const portfolioId = property.portfolioId; @@ -246,9 +240,6 @@ export const columns: ColumnDef[] = [ Actions - setOpenModal(true)}> - Book a survey - navigator.clipboard.writeText(payment.id)} className="text-gray-700 cursor-pointer" @@ -268,25 +259,6 @@ export const columns: ColumnDef[] = [ - {/* ✅ Render modal outside dropdown context */} - {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. 🎉" - /> ); },