refactor data table a bit

This commit is contained in:
2024-07-14 13:22:10 +02:00
parent 1e3effcf76
commit 709ac0296d
2 changed files with 15 additions and 3 deletions

View File

@@ -1,4 +1,7 @@
import { TableView } from "@/components/db-table-view/table"; import {
TableScrollContainer,
TableView,
} from "@/components/db-table-view/table";
import { import {
Button, Button,
DataTablePagination, DataTablePagination,
@@ -230,9 +233,9 @@ export const DataTable = ({
</div> </div>
<div className="rounded-md border min-h-0 h-full w-full min-w-0 flex flex-col"> <div className="rounded-md border min-h-0 h-full w-full min-w-0 flex flex-col">
<div className={"flex flex-col flex-1 overflow-auto relative"}> <TableScrollContainer>
<TableView table={table} columnLength={columns.length} /> <TableView table={table} columnLength={columns.length} />
</div> </TableScrollContainer>
</div> </div>
<DataTablePagination table={table} /> <DataTablePagination table={table} />
</div> </div>

View File

@@ -10,6 +10,7 @@ import {
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { type Table as ReactTable, flexRender } from "@tanstack/react-table"; import { type Table as ReactTable, flexRender } from "@tanstack/react-table";
import { ArrowUp } from "lucide-react"; import { ArrowUp } from "lucide-react";
import type { PropsWithChildren } from "react";
export function TableView<T>({ export function TableView<T>({
table, table,
@@ -108,3 +109,11 @@ export function TableView<T>({
</Table> </Table>
); );
} }
export function TableScrollContainer({ children }: PropsWithChildren) {
return (
<div className={"flex flex-col flex-1 overflow-auto relative"}>
{children}
</div>
);
}