mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-19 05:54:06 +01:00
feat: remove Deals page component; integrate Modal in Portfolio for deal viewing
This commit is contained in:
parent
6e70bdf084
commit
a05aacca59
@ -1,9 +0,0 @@
|
|||||||
import { DataTable } from "@/components/dataTable";
|
|
||||||
|
|
||||||
export default function Deals() {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<p>hello นาา</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@ -27,6 +27,7 @@ import Link from "next/link";
|
|||||||
import { DataTable } from "@/components/dataTable";
|
import { DataTable } from "@/components/dataTable";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import CustomTooltip from "@/components/customToolTip";
|
import CustomTooltip from "@/components/customToolTip";
|
||||||
|
import { Modal } from "@/components/modal";
|
||||||
|
|
||||||
export default async function Portfolio({ params }: { params: { uid: string } }) {
|
export default async function Portfolio({ params }: { params: { uid: string } }) {
|
||||||
const supabase = createSupabaseClient();
|
const supabase = createSupabaseClient();
|
||||||
@ -75,7 +76,15 @@ export default async function Portfolio({ params }: { params: { uid: string } })
|
|||||||
const tags = deals ? await getInvestorProjectTag(supabase, deals) : [];
|
const tags = deals ? await getInvestorProjectTag(supabase, deals) : [];
|
||||||
const latestDeals = deals
|
const latestDeals = deals
|
||||||
? await Promise.all(
|
? 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,
|
...deal,
|
||||||
logo_url: await deal.logo_url,
|
logo_url: await deal.logo_url,
|
||||||
}))
|
}))
|
||||||
@ -99,7 +108,6 @@ export default async function Portfolio({ params }: { params: { uid: string } })
|
|||||||
<CountUpComponent end={totalInvestment} duration={1} />
|
<CountUpComponent end={totalInvestment} duration={1} />
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex flew-rows-3 gap-10 mt-5 w-full">
|
<div className="flex flew-rows-3 gap-10 mt-5 w-full">
|
||||||
<Tabs defaultValue="daily" className="space-y-4 w-full">
|
<Tabs defaultValue="daily" className="space-y-4 w-full">
|
||||||
<TabsList className="grid w-96 grid-cols-3">
|
<TabsList className="grid w-96 grid-cols-3">
|
||||||
@ -235,9 +243,7 @@ export default async function Portfolio({ params }: { params: { uid: string } })
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="mt-5 grid grid-flow-row-dense">
|
<CardContent className="mt-5 grid grid-flow-row-dense">
|
||||||
<RecentFunds data={latestDeals} />
|
<RecentFunds data={latestDeals} />
|
||||||
<div className="mt-5 flex justify-center">
|
<div className="mt-5 flex justify-center">{deals && deals.length ? <Modal /> : undefined}</div>
|
||||||
{deals && deals.length > 5 ? <Button>View More</Button> : undefined}
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -26,7 +26,7 @@ function getTotalInvestment(deals: { deal_amount: number }[]) {
|
|||||||
}
|
}
|
||||||
async function getLatestInvestment(
|
async function getLatestInvestment(
|
||||||
supabase: SupabaseClient,
|
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 llist = [];
|
||||||
const count = 5;
|
const count = 5;
|
||||||
@ -43,6 +43,7 @@ async function getLatestInvestment(
|
|||||||
amount: deals[i].deal_amount,
|
amount: deals[i].deal_amount,
|
||||||
date: new Date(deals[i].created_time),
|
date: new Date(deals[i].created_time),
|
||||||
logo_url: url,
|
logo_url: url,
|
||||||
|
status: deals[i].status,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
26
src/components/modal.tsx
Normal file
26
src/components/modal.tsx
Normal file
@ -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 (
|
||||||
|
<div>
|
||||||
|
<Dialog>
|
||||||
|
<DialogTrigger asChild>
|
||||||
|
<Button>View More</Button>
|
||||||
|
</DialogTrigger>
|
||||||
|
<DialogContent>
|
||||||
|
{/* <DataTable /> */}
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -56,7 +56,22 @@ export const getInvestmentByUserId = (client: SupabaseClient, userId: string) =>
|
|||||||
export function getInvestorDeal(client: SupabaseClient, userId: string) {
|
export function getInvestorDeal(client: SupabaseClient, userId: string) {
|
||||||
return client
|
return client
|
||||||
.from("investment_deal")
|
.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])
|
.in("investor_id", [userId])
|
||||||
.order("created_time", { ascending: true });
|
.order("created_time", { ascending: true });
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user