From ef6e8cf6c00875fffc697134f2bcf43a4cea067e Mon Sep 17 00:00:00 2001 From: Pattadon Date: Tue, 12 Nov 2024 15:17:43 +0700 Subject: [PATCH] feat: update Modal and DataTable components to handle additional deal properties and improve rendering logic --- src/app/portfolio/[uid]/page.tsx | 22 ++++++--- src/components/dataTable.tsx | 77 ++++++++++++++++++++++++-------- src/components/modal.tsx | 21 +++++---- 3 files changed, 83 insertions(+), 37 deletions(-) diff --git a/src/app/portfolio/[uid]/page.tsx b/src/app/portfolio/[uid]/page.tsx index 0ac0a4c..163f77c 100644 --- a/src/app/portfolio/[uid]/page.tsx +++ b/src/app/portfolio/[uid]/page.tsx @@ -244,13 +244,21 @@ export default async function Portfolio({ params }: { params: { uid: string } })
- {/* {deals && deals.length ? { - return { - name: deal.name, - amount: deal.amount, - date: deal.date, - }; - })} /> : undefined} */} + {/* {latestDeals.length} */} + {deals && deals.length ? ( + { + return { + date: item.date, + name: item.name, + amount: item.amount, + status: item.status, + logoURL: item.logo_url, + profileURL: `deals/${item.projectId}` + }; + })} + /> + ) : undefined}
diff --git a/src/components/dataTable.tsx b/src/components/dataTable.tsx index e7f5d96..d4d80f3 100644 --- a/src/components/dataTable.tsx +++ b/src/components/dataTable.tsx @@ -26,19 +26,17 @@ import { import { Input } from "@/components/ui/input"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; -export type Payment = { - data?: { - name?: string; - amount?: number; - avatar?: string; - date?: Date; - logo_url?: string; - status?: string; - profile_url?: string; - }[]; +export type ModalProps = { + date: Date; + amount: number; + name: string; + investorId?: string; + profileURL?: string; + logoURL?: string; + status?: string; }; -export const columns: ColumnDef[] = [ +export const columns: ColumnDef[] = [ { id: "select", header: ({ table }) => ( @@ -59,21 +57,62 @@ export const columns: ColumnDef[] = [ enableHiding: false, }, { - accessorKey: "email", + accessorKey: "name", header: ({ column }) => { return ( ); }, - cell: ({ row }) =>
{row.getValue("email")}
, + cell: ({ row }) =>
{row.getValue("name")}
, }, { accessorKey: "status", header: "Status", - cell: ({ row }) =>
{row.getValue("status")}
, + cell: ({ row }) => ( +
+ + + + +

+

+ +
{row.getValue("status")}
+
+ ), }, { accessorKey: "amount", @@ -92,7 +131,7 @@ export const columns: ColumnDef[] = [ }, ]; -export function DataTable({ data }: { data: Payment[] }) { +export function DataTable({ data }: { data: ModalProps[] }) { const [sorting, setSorting] = React.useState([]); const [columnFilters, setColumnFilters] = React.useState([]); const [columnVisibility, setColumnVisibility] = React.useState({}); @@ -121,9 +160,9 @@ export function DataTable({ data }: { data: Payment[] }) {
table.getColumn("email")?.setFilterValue(event.target.value)} + placeholder="Filter names..." + value={(table.getColumn("name")?.getFilterValue() as string) ?? ""} + onChange={(event) => table.getColumn("name")?.setFilterValue(event.target.value)} className="max-w-sm" /> diff --git a/src/components/modal.tsx b/src/components/modal.tsx index 2de0b43..aa58f19 100644 --- a/src/components/modal.tsx +++ b/src/components/modal.tsx @@ -3,18 +3,17 @@ import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog"; import { Button } from "./ui/button"; import { DataTable } from "./dataTable"; -export type Payment = { - data?: { - name?: string; - amount?: number; - avatar?: string; - date?: Date; - logo_url?: string; - status?: string; - profile_url?: string; - }[]; +export type ModalProps = { + date: Date; + amount: number; + name: string; + investorId?: string; + profileURL?: string; + logoURL?: string; + status?: string; }; -export function Modal({ data }: { data: Payment[] }) { + +export function Modal({ data }: { data: ModalProps[] }) { return (