pos-dashboard-v2/src/components/TablePaginationComponent.tsx

35 lines
969 B
TypeScript
Raw Normal View History

2025-08-05 14:34:36 +07:00
import { Typography, Pagination } from '@mui/material'
2025-08-05 12:35:40 +07:00
2025-08-05 14:34:36 +07:00
const TablePaginationComponent = ({
pageIndex,
pageSize,
totalCount,
onPageChange
}: {
pageIndex: number
pageSize: number
totalCount: number
onPageChange: (event: React.ChangeEvent<unknown>, page: number) => void
}) => {
const start = pageIndex === 1 ? pageIndex : (pageIndex - 1) * pageSize + 1
const end = Math.min((pageIndex) * pageSize, totalCount)
2025-08-05 12:35:40 +07:00
return (
<div className='flex justify-between items-center flex-wrap pli-6 border-bs bs-auto plb-[12.5px] gap-2'>
2025-08-05 14:34:36 +07:00
<Typography color='text.disabled'>{`Showing ${start} to ${end} of ${totalCount} entries`}</Typography>
2025-08-05 12:35:40 +07:00
<Pagination
shape='rounded'
color='primary'
variant='tonal'
2025-08-05 14:34:36 +07:00
count={Math.ceil(totalCount / pageSize)}
page={pageIndex}
onChange={onPageChange}
2025-08-05 12:35:40 +07:00
showFirstButton
showLastButton
/>
</div>
)
}
export default TablePaginationComponent