diff --git a/src/app/components/building-passport/Toolbar.tsx b/src/app/components/building-passport/Toolbar.tsx index 48f7d2e4..e2d98430 100644 --- a/src/app/components/building-passport/Toolbar.tsx +++ b/src/app/components/building-passport/Toolbar.tsx @@ -70,6 +70,11 @@ export function Toolbar({ const [openModal, setOpenModal] = useState(false); const [showToast, setShowToast] = useState(false); + console.log(propertyId, "PropertyID") + console.log(portfolioId, "porfolio id") + console.log(propertyMeta, "property meta") + console.log(decentHomes, "decent homes") + function handleClickSettings() { console.log("Settings were clicked, implement me"); } @@ -175,7 +180,7 @@ export function Toolbar({ onOpenChange={setOpenModal} propertyId={BigInt(propertyId)} portfolioId={portfolioId} - address={propertyMeta.address} + propertyMeta={propertyMeta} onSuccess={() => setShowToast(true)} /> )} diff --git a/src/app/portfolio/[slug]/building-passport/[propertyId]/layout.tsx b/src/app/portfolio/[slug]/building-passport/[propertyId]/layout.tsx index 2c470411..ba669f7c 100644 --- a/src/app/portfolio/[slug]/building-passport/[propertyId]/layout.tsx +++ b/src/app/portfolio/[slug]/building-passport/[propertyId]/layout.tsx @@ -27,6 +27,7 @@ export default async function DashboardLayout(props: { const propertyId = params.propertyId ?? ""; const portfolioId = params.slug ?? ""; + // The layout is a server component by default so we can fetch meta data here const propertyMeta = await getPropertyMeta(params.propertyId); diff --git a/src/app/portfolio/[slug]/components/BookSurveyModal.tsx b/src/app/portfolio/[slug]/components/BookSurveyModal.tsx index a3a7b521..2b9deeb9 100644 --- a/src/app/portfolio/[slug]/components/BookSurveyModal.tsx +++ b/src/app/portfolio/[slug]/components/BookSurveyModal.tsx @@ -12,24 +12,38 @@ import { Input } from "@/app/shadcn_components/ui/input"; import { Label } from "@/app/shadcn_components/ui/label"; import { useState, useEffect } from "react"; import { useMutation } from "@tanstack/react-query"; +import { PropertyMeta } from "@/app/db/schema/property"; +import { cache } from "react"; +import { getServerSession } from "next-auth"; +import { AuthOptions } from "@/app/api/auth/[...nextauth]/authOptions"; interface BookSurveyModalProps { open: boolean; onOpenChange: (open: boolean) => void; propertyId: bigint; portfolioId: string; - address: string; + propertyMeta: PropertyMeta; onSuccess?: () => void; // ✅ fix: properly declare optional callback } +const getSession = cache(async () => { + const session = await getServerSession(AuthOptions); + return session; +}); + export default function BookSurveyModal({ open, onOpenChange, propertyId, portfolioId, - address, + propertyMeta, onSuccess, // ✅ fix: remove “?:” here, we already declared it optional in interface }: BookSurveyModalProps) { + + const user = getSession(); + console.log(user, "user details"); + + // 🧠 Simple mutation to call your HubSpot API const bookSurveyMutation = useMutation({ mutationFn: async () => { @@ -37,7 +51,7 @@ export default function BookSurveyModal({ method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ - dealName: address, + dealName: propertyMeta.address, pipelineId: "2400089278", dealStageId: "3660660975", propertyId: propertyId.toString(),