diff --git a/src/app/(investment)/deals/page.tsx b/src/app/(investment)/deals/page.tsx index 9ebb50d..7655b99 100644 --- a/src/app/(investment)/deals/page.tsx +++ b/src/app/(investment)/deals/page.tsx @@ -12,6 +12,7 @@ import { Input } from "@/components/ui/input"; import { ProjectSection } from "@/components/ProjectSection"; import { ShowFilter } from "./ShowFilter"; import { Button } from "@/components/ui/button"; +import { sumByKey } from "@/lib/utils"; export default function Deals() { const supabase = createSupabaseClient(); @@ -71,8 +72,8 @@ export default function Deals() { location: project.business_location, tags: project.tags.map((tag) => tag.tag_name), min_investment: project.min_investment || 0, - total_investor: project.total_investment || 0, - total_raise: project.total_investment || 0, + total_investor: new Set(project.investment_deal.map((deal) => deal.investor_id)).size || 0, + total_raise: sumByKey(project.investment_deal, "deal_amount") || 0, })) || []; const clearAll = () => { diff --git a/src/app/page.tsx b/src/app/page.tsx index 44ce4a3..3fca219 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -19,6 +19,12 @@ export default async function Home() { const supabase = createSupabaseClient(); const { data: topProjectsData, error: topProjectsError } = await getTopProjects(supabase); + const formattedProjects = + topProjectsData?.map((project) => ({ + ...project, + id: project.project_id, + })) || []; + return (
@@ -100,7 +106,7 @@ export default async function Home() {
) : ( }> - + )}
diff --git a/src/lib/data/projectQuery.ts b/src/lib/data/projectQuery.ts index f4f5e21..2a64029 100644 --- a/src/lib/data/projectQuery.ts +++ b/src/lib/data/projectQuery.ts @@ -151,6 +151,10 @@ function searchProjectsQuery( business_type:value ), business_location:location + ), + investment_deal ( + deal_amount, + investor_id ) ` ) @@ -207,6 +211,7 @@ const getProjectByUserId = (client: SupabaseClient, userId: string) => { ` id, project_name, + project_short_description, business_id:business!inner ( user_id ),