blob: 797d7a08e32d1d8807ca8562871c43e44453f9a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
import { useEffect } from "react";
import { UsePaginationQueryResult } from "@/apis/queries/hooks";
import SimpleTable, { SimpleTableProps } from "@/components/tables/SimpleTable";
import { LoadingProvider } from "@/contexts";
import { ScrollToTop } from "@/utilities";
import PageControl from "./PageControl";
type Props<T extends object> = Omit<SimpleTableProps<T>, "data"> & {
query: UsePaginationQueryResult<T>;
};
export default function QueryPageTable<T extends object>(props: Props<T>) {
const { query, ...remain } = props;
const {
data = { data: [], total: 0 },
paginationStatus: { page, pageCount, totalCount, pageSize, isPageLoading },
controls: { gotoPage },
} = query;
useEffect(() => {
ScrollToTop();
}, [page]);
return (
<LoadingProvider value={isPageLoading}>
<SimpleTable {...remain} data={data.data}></SimpleTable>
<PageControl
count={pageCount}
index={page}
size={pageSize}
total={totalCount}
goto={gotoPage}
></PageControl>
</LoadingProvider>
);
}
|