feat: add user last seen field

This commit is contained in:
Sonny
2024-10-07 02:07:39 +02:00
parent 24cea2b0b2
commit c8fb5af44d
11 changed files with 103 additions and 36 deletions

View File

@@ -6,6 +6,7 @@ import {
getPaginationRowModel,
getSortedRowModel,
PaginationState,
SortingState,
useReactTable,
} from '@tanstack/react-table';
import { useState } from 'react';
@@ -50,13 +51,19 @@ const Resizer = styled.div<{ isResizing: boolean }>(
type TableProps<T> = {
columns: ColumnDef<T>[];
data: T[];
defaultSorting?: SortingState;
};
export default function Table<T>({ columns, data }: TableProps<T>) {
export default function Table<T>({
columns,
data,
defaultSorting = [],
}: TableProps<T>) {
const [pagination, setPagination] = useState<PaginationState>({
pageIndex: 0,
pageSize: 10,
});
const [sorting, setSorting] = useState<SortingState>(defaultSorting);
const table = useReactTable({
data,
@@ -65,11 +72,13 @@ export default function Table<T>({ columns, data }: TableProps<T>) {
columnResizeMode: 'onChange',
state: {
pagination,
sorting,
},
onPaginationChange: setPagination,
getCoreRowModel: getCoreRowModel(),
getPaginationRowModel: getPaginationRowModel(),
getSortedRowModel: getSortedRowModel(),
onSortingChange: setSorting,
debugTable: true,
});