-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added attribute-table component and refactored ABCIEventsTable to use…
… it. duplicates data-table but with single table header for event type. updated block and transaction page.
- Loading branch information
Showing
6 changed files
with
134 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
"use client"; | ||
|
||
import { | ||
type ColumnDef, | ||
flexRender, | ||
getCoreRowModel, | ||
useReactTable, | ||
type VisibilityState, | ||
} from "@tanstack/react-table"; | ||
|
||
import { | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableHead, | ||
TableHeader, | ||
TableRow, | ||
} from "@/components/ui/Table"; | ||
|
||
interface AttributeTableProps<TData, TValue> { | ||
className?: string, | ||
header?: string, | ||
columns: Array<ColumnDef<TData, TValue>>, | ||
columnVisibility?: VisibilityState, | ||
data: TData[], | ||
} | ||
|
||
export function AttributeTable<TData, TValue>({ | ||
className, | ||
header, | ||
columns, | ||
columnVisibility, | ||
data, | ||
}: AttributeTableProps<TData, TValue>) { | ||
|
||
const table = useReactTable({ | ||
data, | ||
columns, | ||
getCoreRowModel: getCoreRowModel(), | ||
initialState: { | ||
columnVisibility, | ||
}, | ||
}); | ||
|
||
console.log("Header groups: ", table.getHeaderGroups()); | ||
|
||
|
||
return ( | ||
<div className={`${className}`}> | ||
<div className="rounded-md border"> | ||
<Table> | ||
<TableHeader className="bg-slate-200"> | ||
{table.getHeaderGroups()[0].headers.map((headerGroup) => ( | ||
<TableRow key={headerGroup.id}> | ||
{ | ||
<TableHead key={headerGroup.id} colSpan={2}> | ||
{headerGroup.isPlaceholder | ||
? null | ||
: flexRender( | ||
headerGroup.column.columnDef.header, | ||
headerGroup.getContext(), | ||
)} | ||
</TableHead> | ||
} | ||
</TableRow> | ||
))} | ||
</TableHeader> | ||
<TableBody> | ||
{table.getRowModel().rows?.length ? ( | ||
table.getRowModel().rows.map((row) => ( | ||
<TableRow | ||
className="bg-white" | ||
key={row.id} | ||
data-state={row.getIsSelected() && "selected"} | ||
> | ||
{row.getVisibleCells().map((cell) => ( | ||
<TableCell key={cell.id} className="sm:p-4 p-1"> | ||
{flexRender(cell.column.columnDef.cell, cell.getContext())} | ||
</TableCell> | ||
))} | ||
</TableRow> | ||
)) | ||
) : ( | ||
<TableRow> | ||
<TableCell colSpan={columns.length} className="h-24 text-center"> | ||
No results. | ||
</TableCell> | ||
</TableRow> | ||
)} | ||
</TableBody> | ||
</Table> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters