From a05aacca592a9b9012fedef8fa7abb6ef6fcc2aa Mon Sep 17 00:00:00 2001 From: Pattadon Date: Tue, 12 Nov 2024 10:41:45 +0700 Subject: [PATCH] feat: remove Deals page component; integrate Modal in Portfolio for deal viewing --- src/app/dashboard/deals/page.tsx | 9 --------- src/app/portfolio/[uid]/page.tsx | 16 +++++++++++----- src/app/portfolio/[uid]/query.ts | 3 ++- src/components/modal.tsx | 26 ++++++++++++++++++++++++++ src/lib/data/investmentQuery.ts | 17 ++++++++++++++++- 5 files changed, 55 insertions(+), 16 deletions(-) delete mode 100644 src/app/dashboard/deals/page.tsx create mode 100644 src/components/modal.tsx diff --git a/src/app/dashboard/deals/page.tsx b/src/app/dashboard/deals/page.tsx deleted file mode 100644 index 4b70825..0000000 --- a/src/app/dashboard/deals/page.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { DataTable } from "@/components/dataTable"; - -export default function Deals() { - return ( -
-

hello นาา

-
- ); -} diff --git a/src/app/portfolio/[uid]/page.tsx b/src/app/portfolio/[uid]/page.tsx index 5531e8f..14f0440 100644 --- a/src/app/portfolio/[uid]/page.tsx +++ b/src/app/portfolio/[uid]/page.tsx @@ -27,6 +27,7 @@ import Link from "next/link"; import { DataTable } from "@/components/dataTable"; import { Button } from "@/components/ui/button"; import CustomTooltip from "@/components/customToolTip"; +import { Modal } from "@/components/modal"; export default async function Portfolio({ params }: { params: { uid: string } }) { const supabase = createSupabaseClient(); @@ -75,7 +76,15 @@ export default async function Portfolio({ params }: { params: { uid: string } }) const tags = deals ? await getInvestorProjectTag(supabase, deals) : []; const latestDeals = deals ? await Promise.all( - (await getLatestInvestment(supabase, deals)).map(async (deal) => ({ + ( + await getLatestInvestment( + supabase, + deals.map((deal) => ({ + ...deal, + status: deal.deal_status, + })) + ) + ).map(async (deal) => ({ ...deal, logo_url: await deal.logo_url, })) @@ -99,7 +108,6 @@ export default async function Portfolio({ params }: { params: { uid: string } })

-
@@ -235,9 +243,7 @@ export default async function Portfolio({ params }: { params: { uid: string } }) -
- {deals && deals.length > 5 ? : undefined} -
+
{deals && deals.length ? : undefined}
diff --git a/src/app/portfolio/[uid]/query.ts b/src/app/portfolio/[uid]/query.ts index 3333de8..1ea68ff 100644 --- a/src/app/portfolio/[uid]/query.ts +++ b/src/app/portfolio/[uid]/query.ts @@ -26,7 +26,7 @@ function getTotalInvestment(deals: { deal_amount: number }[]) { } async function getLatestInvestment( supabase: SupabaseClient, - deals: { project_id: number; deal_amount: number; created_time: Date;}[] + deals: { project_id: number; deal_amount: number; created_time: Date; status: string}[] ) { const llist = []; const count = 5; @@ -43,6 +43,7 @@ async function getLatestInvestment( amount: deals[i].deal_amount, date: new Date(deals[i].created_time), logo_url: url, + status: deals[i].status, }); } diff --git a/src/components/modal.tsx b/src/components/modal.tsx new file mode 100644 index 0000000..ed3c435 --- /dev/null +++ b/src/components/modal.tsx @@ -0,0 +1,26 @@ +"use client"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog"; +import { Button } from "./ui/button"; +import { DataTable } from "./dataTable"; + +export function Modal() { + return ( +
+ + + + + + {/* */} + + +
+ ); +} diff --git a/src/lib/data/investmentQuery.ts b/src/lib/data/investmentQuery.ts index df9a944..49f7b13 100644 --- a/src/lib/data/investmentQuery.ts +++ b/src/lib/data/investmentQuery.ts @@ -56,7 +56,22 @@ export const getInvestmentByUserId = (client: SupabaseClient, userId: string) => export function getInvestorDeal(client: SupabaseClient, userId: string) { return client .from("investment_deal") - .select("*") + .select( + ` + id, + ...deal_status_id( + deal_status:value + ), + project_id, + deal_amount, + created_time, + ...profiles ( + investor_id:id, + username, + avatar_url + ) + ` + ) .in("investor_id", [userId]) .order("created_time", { ascending: true }); }