diff --git a/packages/common/business_components/src/ui/table/index.tsx b/packages/common/business_components/src/ui/table/index.tsx index 9635a7e21..99199d163 100644 --- a/packages/common/business_components/src/ui/table/index.tsx +++ b/packages/common/business_components/src/ui/table/index.tsx @@ -1,50 +1,78 @@ -import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@common/components"; -import UiPageNations from "./uiPageNations"; +'use client'; -type UiTableProps = { - headName: React.ReactNode | undefined; - tableData: { [key: string]: string | number | boolean }[]; - headlist: UiHeadProps[]; - pageSize: number; +import { useEffect, useState } from "react"; +import { + Pagination, + PaginationContent, + PaginationItem, + PaginationPrevious, + PaginationLink, + PaginationNext +} from "./lib/pagination"; + +interface CommonPageNationsProps { total: number; - children: React.ReactNode | undefined; - cellClick : ((index:number|undefined)=>void) | undefined; + cur: number; + pageSize: number; } -type UiHeadProps = { - id: string; - title: string; -} +export default function UiPageNations(commonPageNationsProps: CommonPageNationsProps) { + const [pageProps, setPageProps] = useState(commonPageNationsProps); -export function UiTable({ tableData, headlist, pageSize, total, children, headName, cellClick }: UiTableProps) { - const cur = 1; + useEffect(() => { + setPageProps(commonPageNationsProps); + }, [commonPageNationsProps]); + + const totalPages = Math.ceil(pageProps.total / pageProps.pageSize); + const pagesPerGroup = 10; + const currentGroup = Math.floor((pageProps.cur - 1) / pagesPerGroup); + const startPage = currentGroup * pagesPerGroup + 1; + const endPage = Math.min(startPage + pagesPerGroup - 1, totalPages); + + const handlePageChange = (page: number) => { + setPageProps({ ...pageProps, cur: page }); + }; return ( - <> - {headName ?