From 58aa3408629c7ac51657b4271445b3f2ec374461 Mon Sep 17 00:00:00 2001 From: ryjiang Date: Wed, 22 Jan 2025 16:16:47 +0800 Subject: [PATCH] show pagination for role page Signed-off-by: ryjiang --- client/src/pages/user/Roles.tsx | 43 ++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/client/src/pages/user/Roles.tsx b/client/src/pages/user/Roles.tsx index b0bb8d77..b4a67010 100644 --- a/client/src/pages/user/Roles.tsx +++ b/client/src/pages/user/Roles.tsx @@ -3,7 +3,7 @@ import { Theme, Chip } from '@mui/material'; import { useTranslation } from 'react-i18next'; import { UserService } from '@/http'; import { rootContext, dataContext } from '@/context'; -import { useNavigationHook } from '@/hooks'; +import { useNavigationHook, usePaginationHook } from '@/hooks'; import AttuGrid from '@/components/grid/Grid'; import DeleteTemplate from '@/components/customDialog/DeleteDialogTemplate'; import UpdateRoleDialog from './dialogs/UpdateRoleDialog'; @@ -14,6 +14,7 @@ import type { ToolBarConfig, } from '@/components/grid/Types'; import type { DeleteRoleParams, RoleData } from './Types'; +import { getLabelDisplayedRows } from '@/pages/search/Utils'; const useStyles = makeStyles((theme: Theme) => ({ wrapper: { @@ -28,6 +29,7 @@ const Roles = () => { useNavigationHook(ALL_ROUTER_TYPES.USER); const classes = useStyles(); const { database } = useContext(dataContext); + const [loading, setLoading] = useState(false); const [roles, setRoles] = useState([]); const [selectedRole, setSelectedRole] = useState([]); @@ -201,25 +203,42 @@ const Roles = () => { fetchRoles(); }, [database]); + const { + pageSize, + handlePageSize, + currentPage, + handleCurrentPage, + total, + data: result, + order, + orderBy, + handleGridSort, + } = usePaginationHook(roles || []); + + const handlePageChange = (e: any, page: number) => { + handleCurrentPage(page); + }; + return (
);