Files
pawol.nu/components/awtis/pajinasyon.js
T

48 lines
1.0 KiB
JavaScript
Raw Normal View History

2020-12-11 01:39:21 +01:00
import PropTypes from 'prop-types'
import {useRouter} from 'next/router'
2022-01-19 07:06:26 +04:00
import {styled} from '@mui/material/styles'
import Pagination from '@mui/material/Pagination'
import {Grid} from '@mui/material'
2020-12-11 01:39:21 +01:00
2022-01-19 06:35:04 +04:00
const PREFIX = 'pajinasyon'
const classes = {
root: `${PREFIX}-root`
}
const StyledGrid = styled(Grid)((
{
theme
}
) => ({
[`& .${classes.root}`]: {
2020-12-11 01:39:21 +01:00
'& > *': {
2022-01-21 07:56:15 +04:00
marginBottom: theme.spacing(2),
2022-01-22 13:42:09 +04:00
marginTop: theme.spacing(2)
2020-12-11 01:39:21 +01:00
}
}
}))
export default function Pajinasyon({pajTotal, paj}) {
const router = useRouter()
2022-01-19 06:35:04 +04:00
2020-12-11 01:39:21 +01:00
const handleChange = (event, value) => {
const href = `/awtis?paj&paj=${value}`
const as = `/awtis/paj/${value}`
router.push(href, as)
}
return (
2022-01-20 00:25:43 +04:00
<StyledGrid container justifyContent='center'>
2020-12-11 01:39:21 +01:00
<div className={classes.root}>
2020-12-12 03:28:51 +01:00
<Pagination size='small' page={paj} count={pajTotal} color='primary' onChange={handleChange} />
2020-12-11 01:39:21 +01:00
</div>
2022-01-19 06:35:04 +04:00
</StyledGrid>
2020-12-11 01:39:21 +01:00
)
}
Pajinasyon.propTypes = {
pajTotal: PropTypes.number.isRequired,
paj: PropTypes.number.isRequired
}