continue Event page
This commit is contained in:
@@ -1,28 +1,32 @@
|
||||
"use client";
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import SortableTable, { Pagination, SortableTableProps } from "./Table";
|
||||
import { PrismaClient } from "@repo/db";
|
||||
import { getData } from "./pagiantedTableActions";
|
||||
'use client';
|
||||
import { useEffect, useState, useCallback } from 'react';
|
||||
import SortableTable, { Pagination, SortableTableProps } from './Table';
|
||||
import { PrismaClient } from '@repo/db';
|
||||
import { getData } from './pagiantedTableActions';
|
||||
|
||||
interface PaginatedTableProps<TData>
|
||||
extends Omit<SortableTableProps<TData>, "data"> {
|
||||
extends Omit<SortableTableProps<TData>, 'data'> {
|
||||
prismaModel: keyof PrismaClient;
|
||||
filter?: Record<string, any>;
|
||||
rowsPerPage?: number;
|
||||
showEditButton?: boolean;
|
||||
searchFields: string[];
|
||||
searchFields?: string[];
|
||||
include?: Record<string, boolean>[];
|
||||
}
|
||||
|
||||
export function PaginatedTable<TData>({
|
||||
prismaModel,
|
||||
rowsPerPage = 10,
|
||||
showEditButton = false,
|
||||
searchFields,
|
||||
searchFields = [],
|
||||
filter,
|
||||
include,
|
||||
...restProps
|
||||
}: PaginatedTableProps<TData>) {
|
||||
const [data, setData] = useState<TData[]>([]);
|
||||
const [page, setPage] = useState(0);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [searchTerm, setSearchTerm] = useState('');
|
||||
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState(searchTerm);
|
||||
|
||||
const debounce = (func: Function, delay: number) => {
|
||||
@@ -46,7 +50,8 @@ export function PaginatedTable<TData>({
|
||||
rowsPerPage,
|
||||
page * rowsPerPage,
|
||||
debouncedSearchTerm,
|
||||
searchFields
|
||||
searchFields,
|
||||
filter
|
||||
).then((result) => {
|
||||
if (result) {
|
||||
setData(result.data);
|
||||
|
||||
Reference in New Issue
Block a user