Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | 12x 8x 8x 1x 1x 8x 1x | import React from 'react';
import {
Box,
Pagination,
FormControl,
Select,
MenuItem,
Typography,
SelectChangeEvent,
} from '@mui/material';
import { useTranslation } from 'react-i18next';
interface UserPaginationProps {
page: number;
totalPages: number;
limit: number;
onPageChange: (page: number) => void;
onLimitChange: (limit: number) => void;
namespace?: string;
}
const UserPagination: React.FC<UserPaginationProps> = ({
page,
totalPages,
limit,
onPageChange,
onLimitChange,
namespace = 'userManagement',
}) => {
const { t } = useTranslation(namespace);
const handleLimitChange = (event: SelectChangeEvent<number>) => {
const newLimit = Number(event.target.value);
onLimitChange(newLimit);
};
return (
<Box
sx={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
mt: 3,
flexWrap: 'wrap',
gap: 2,
}}
>
{/* Pagination Controls */}
<Pagination
count={totalPages}
page={page}
onChange={(_, newPage) => onPageChange(newPage)}
color="primary"
showFirstButton
showLastButton
siblingCount={1}
boundaryCount={1}
/>
{/* Items Per Page Selector */}
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
<Typography variant="body2" color="text.secondary">
{t('pagination.itemsPerPage')}:
</Typography>
<FormControl size="small">
<Select
value={limit}
onChange={handleLimitChange}
aria-label={t('pagination.itemsPerPage')}
>
<MenuItem value={10}>10</MenuItem>
<MenuItem value={20}>20</MenuItem>
<MenuItem value={50}>50</MenuItem>
<MenuItem value={100}>100</MenuItem>
</Select>
</FormControl>
</Box>
</Box>
);
};
export default UserPagination;
|