fix: show investor and reserve fund

This commit is contained in:
Sosokker 2024-11-07 03:19:13 +07:00
parent e7a1f54b43
commit 57b31ec43c
3 changed files with 15 additions and 3 deletions

View File

@ -12,6 +12,7 @@ import { Input } from "@/components/ui/input";
import { ProjectSection } from "@/components/ProjectSection"; import { ProjectSection } from "@/components/ProjectSection";
import { ShowFilter } from "./ShowFilter"; import { ShowFilter } from "./ShowFilter";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { sumByKey } from "@/lib/utils";
export default function Deals() { export default function Deals() {
const supabase = createSupabaseClient(); const supabase = createSupabaseClient();
@ -71,8 +72,8 @@ export default function Deals() {
location: project.business_location, location: project.business_location,
tags: project.tags.map((tag) => tag.tag_name), tags: project.tags.map((tag) => tag.tag_name),
min_investment: project.min_investment || 0, min_investment: project.min_investment || 0,
total_investor: project.total_investment || 0, total_investor: new Set(project.investment_deal.map((deal) => deal.investor_id)).size || 0,
total_raise: project.total_investment || 0, total_raise: sumByKey(project.investment_deal, "deal_amount") || 0,
})) || []; })) || [];
const clearAll = () => { const clearAll = () => {

View File

@ -19,6 +19,12 @@ export default async function Home() {
const supabase = createSupabaseClient(); const supabase = createSupabaseClient();
const { data: topProjectsData, error: topProjectsError } = await getTopProjects(supabase); const { data: topProjectsData, error: topProjectsError } = await getTopProjects(supabase);
const formattedProjects =
topProjectsData?.map((project) => ({
...project,
id: project.project_id,
})) || [];
return ( return (
<main> <main>
<div className="relative mx-auto"> <div className="relative mx-auto">
@ -100,7 +106,7 @@ export default async function Home() {
</div> </div>
) : ( ) : (
<Suspense fallback={<ProjectsLoader />}> <Suspense fallback={<ProjectsLoader />}>
<ProjectSection projectsData={topProjectsData} /> <ProjectSection projectsData={formattedProjects} />
</Suspense> </Suspense>
)} )}
<div className="self-center py-5 scale-75 md:scale-100"> <div className="self-center py-5 scale-75 md:scale-100">

View File

@ -151,6 +151,10 @@ function searchProjectsQuery(
business_type:value business_type:value
), ),
business_location:location business_location:location
),
investment_deal (
deal_amount,
investor_id
) )
` `
) )
@ -207,6 +211,7 @@ const getProjectByUserId = (client: SupabaseClient, userId: string) => {
` `
id, id,
project_name, project_name,
project_short_description,
business_id:business!inner ( business_id:business!inner (
user_id user_id
), ),