diff --git a/src/app/(investment)/deals/[id]/page.tsx b/src/app/(investment)/deals/[id]/page.tsx index 2322aef..0f6b4df 100644 --- a/src/app/(investment)/deals/[id]/page.tsx +++ b/src/app/(investment)/deals/[id]/page.tsx @@ -16,6 +16,7 @@ import { isOwnerOfProject } from "./query"; import { UpdateTab } from "./UpdateTab"; import remarkGfm from "remark-gfm"; import Gallery from "@/components/carousel"; +import { getProjectCardData } from "@/lib/data/projectQuery"; const PHOTO_MATERIAL_ID = 2; @@ -62,6 +63,8 @@ export default async function ProjectDealPage({ params }: { params: { id: number const projectBusinessOwnerId = projectData.user_id; const dealList = await getDealList(projectBusinessOwnerId); + const { data, error } = await getProjectCardData(supabase, [params.id.toString()]); + const totalDealAmount = sumByKey(dealList, "deal_amount"); // timeDiff, if negative convert to zero const timeDiff = Math.max(new Date(projectData.investment_deadline).getTime() - new Date().getTime(), 0); @@ -76,6 +79,10 @@ export default async function ProjectDealPage({ params }: { params: { id: number ) : [{ src: "/boiler1.jpg", alt: "Default Boiler Image" }]; + if (error) { + throw new Error("Error fetching data"); + } + return (
@@ -109,9 +116,9 @@ export default async function ProjectDealPage({ params }: { params: { id: number
-

${totalDealAmount}

+

${data ? data[0].total_raise : 0}

- {toPercentage(totalDealAmount, projectData?.target_investment)}% raised of $ + {data ? toPercentage(totalDealAmount, data[0].total_raise) : 0}% raised of $ {projectData?.target_investment} max goal

-

{dealList.length}

+

{data ? data[0].total_investor : 0}

Investors