2021-09-21 21:28:04 +02:00
|
|
|
import {useState} from 'react'
|
2020-12-11 01:36:54 +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 AppBar from '@mui/material/AppBar'
|
|
|
|
|
import Tabs from '@mui/material/Tabs'
|
|
|
|
|
import Tab from '@mui/material/Tab'
|
|
|
|
|
import Typography from '@mui/material/Typography'
|
|
|
|
|
import Box from '@mui/material/Box'
|
2020-12-11 01:36:54 +01:00
|
|
|
|
2022-01-19 06:35:04 +04:00
|
|
|
const PREFIX = 'navigasyon'
|
|
|
|
|
|
|
|
|
|
const classes = {
|
|
|
|
|
root: `${PREFIX}-root`
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-20 20:29:11 +04:00
|
|
|
const Appdiv = styled('div')((
|
2022-01-19 06:35:04 +04:00
|
|
|
{
|
|
|
|
|
theme
|
|
|
|
|
}
|
|
|
|
|
) => ({
|
|
|
|
|
[`& .${classes.root}`]: {
|
|
|
|
|
flexGrow: 1,
|
|
|
|
|
width: '100%',
|
|
|
|
|
backgroundColor: theme.palette.background.paper
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
|
2020-12-11 01:36:54 +01:00
|
|
|
const tabRouteHref = [
|
|
|
|
|
'/',
|
2021-05-22 23:43:21 +02:00
|
|
|
'/teks',
|
2021-09-29 18:59:31 +02:00
|
|
|
'/awtis?paj&paj=1',
|
2021-05-24 13:05:46 +02:00
|
|
|
'/soumet'
|
2020-12-11 01:36:54 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
const tabRouteAs = [
|
|
|
|
|
'/',
|
2021-05-22 23:43:21 +02:00
|
|
|
'/teks',
|
2021-09-29 18:59:31 +02:00
|
|
|
'/awtis/paj/1',
|
2021-05-24 13:05:46 +02:00
|
|
|
'/soumet'
|
2020-12-11 01:36:54 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
function TabPanel(props) {
|
|
|
|
|
const {children, value, index, ...other} = props
|
|
|
|
|
|
|
|
|
|
return (
|
2022-01-20 20:29:11 +04:00
|
|
|
<div
|
2020-12-11 01:36:54 +01:00
|
|
|
role='tabpanel'
|
|
|
|
|
hidden={value !== index}
|
|
|
|
|
id={`scrollable-force-tabpanel-${index}`}
|
|
|
|
|
aria-labelledby={`scrollable-force-tab-${index}`}
|
|
|
|
|
{...other}
|
|
|
|
|
>
|
|
|
|
|
{value === index && (
|
|
|
|
|
<Box p={3}>
|
|
|
|
|
<Typography component='div'>{children}</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
)}
|
2022-01-20 20:29:11 +04:00
|
|
|
</div>
|
2020-12-11 01:36:54 +01:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TabPanel.propTypes = {
|
|
|
|
|
children: PropTypes.node,
|
|
|
|
|
index: PropTypes.any.isRequired,
|
|
|
|
|
value: PropTypes.any.isRequired
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function a11yProps(index) {
|
|
|
|
|
return {
|
|
|
|
|
id: `scrollable-force-tab-${index}`,
|
|
|
|
|
'aria-controls': `scrollable-force-tabpanel-${index}`
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function Navigasyon({selectedTab}) {
|
|
|
|
|
const router = useRouter()
|
2022-01-19 06:35:04 +04:00
|
|
|
|
2021-09-21 21:28:04 +02:00
|
|
|
const [value, setValue] = useState(0)
|
2020-12-11 01:36:54 +01:00
|
|
|
|
|
|
|
|
const handleChange = (event, newValue) => {
|
|
|
|
|
setValue(newValue)
|
|
|
|
|
|
2020-12-16 00:14:43 +01:00
|
|
|
if (newValue !== selectedTab) {
|
2020-12-17 23:19:21 +01:00
|
|
|
router.push(tabRouteHref[newValue], tabRouteAs[newValue]).then(() => window.scrollTo(0, 0))
|
2020-12-16 00:14:43 +01:00
|
|
|
}
|
2020-12-11 01:36:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2022-01-20 20:29:11 +04:00
|
|
|
<Appdiv>
|
|
|
|
|
<div className={classes.root}>
|
|
|
|
|
<AppBar style={{zIndex: 1}} position='fixed' color='default'>
|
|
|
|
|
<Tabs
|
|
|
|
|
centered
|
|
|
|
|
value={selectedTab}
|
|
|
|
|
variant='fullWidth'
|
|
|
|
|
indicatorColor='primary'
|
|
|
|
|
textColor='primary'
|
|
|
|
|
aria-label='tabs menu'
|
|
|
|
|
onChange={handleChange}
|
|
|
|
|
>
|
2022-01-22 13:41:29 +04:00
|
|
|
<Tab label='Accueil' {...a11yProps(0)} />
|
|
|
|
|
<Tab label='Textes' {...a11yProps(1)} />
|
|
|
|
|
<Tab label='Artistes' {...a11yProps(2)} />
|
|
|
|
|
<Tab label='Soumettre' {...a11yProps(3)} />
|
2022-01-20 20:29:11 +04:00
|
|
|
</Tabs>
|
|
|
|
|
</AppBar>
|
|
|
|
|
<TabPanel value={value} index={0} />
|
|
|
|
|
<TabPanel value={value} index={1} />
|
|
|
|
|
<TabPanel value={value} index={2} />
|
|
|
|
|
<TabPanel value={value} index={3} />
|
|
|
|
|
</div>
|
|
|
|
|
</Appdiv>
|
|
|
|
|
)
|
2020-12-11 01:36:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Navigasyon.propTypes = {
|
|
|
|
|
selectedTab: PropTypes.number.isRequired
|
|
|
|
|
}
|