2022-01-24 21:06:52 +04:00
|
|
|
import {useEffect, useState} from 'react'
|
2020-12-13 23:20:07 +01:00
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
import Link from 'next/link'
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
Toolbar,
|
|
|
|
|
Typography,
|
|
|
|
|
AppBar,
|
|
|
|
|
CssBaseline,
|
|
|
|
|
Drawer,
|
|
|
|
|
Hidden,
|
2022-01-24 21:06:52 +04:00
|
|
|
IconButton
|
2022-01-19 07:06:26 +04:00
|
|
|
} from '@mui/material'
|
2020-12-13 23:20:07 +01:00
|
|
|
|
2022-01-19 07:06:26 +04:00
|
|
|
import KeyboardBackspaceIcon from '@mui/icons-material/KeyboardBackspace'
|
2020-12-13 23:20:07 +01:00
|
|
|
|
2022-01-19 07:06:26 +04:00
|
|
|
import MenuIcon from '@mui/icons-material/Menu'
|
2020-12-13 23:20:07 +01:00
|
|
|
|
2022-01-19 07:06:26 +04:00
|
|
|
import {useTheme, styled} from '@mui/material/styles'
|
2020-12-13 23:20:07 +01:00
|
|
|
|
|
|
|
|
import DrawerBar from './drawer-bar'
|
|
|
|
|
import DenyeTeks from './denye-teks'
|
2020-12-15 08:50:14 +01:00
|
|
|
import VweKouteAchte from './vwe-koute-achte'
|
2022-01-24 21:06:52 +04:00
|
|
|
import Teks from './teks'
|
2021-06-02 02:24:19 +02:00
|
|
|
|
2022-01-19 06:35:04 +04:00
|
|
|
const PREFIX = 'teks-drawer'
|
2020-12-13 23:20:07 +01:00
|
|
|
|
2022-01-19 06:35:04 +04:00
|
|
|
const classes = {
|
|
|
|
|
root: `${PREFIX}-root`,
|
|
|
|
|
drawer: `${PREFIX}-drawer`,
|
|
|
|
|
appBar: `${PREFIX}-appBar`,
|
|
|
|
|
menuButton: `${PREFIX}-menuButton`,
|
|
|
|
|
toolbar: `${PREFIX}-toolbar`,
|
|
|
|
|
drawerPaper: `${PREFIX}-drawerPaper`,
|
|
|
|
|
content: `${PREFIX}-content`,
|
|
|
|
|
list: `${PREFIX}-list`,
|
|
|
|
|
form: `${PREFIX}-form`,
|
|
|
|
|
gridText: `${PREFIX}-gridText`,
|
|
|
|
|
grid: `${PREFIX}-grid`,
|
|
|
|
|
koute: `${PREFIX}-koute`,
|
2022-01-24 21:06:52 +04:00
|
|
|
vwe: `${PREFIX}-vwe`
|
2022-01-19 06:35:04 +04:00
|
|
|
}
|
2020-12-13 23:20:07 +01:00
|
|
|
|
2022-01-19 06:35:04 +04:00
|
|
|
const Root = styled('div')((
|
|
|
|
|
{
|
|
|
|
|
theme
|
|
|
|
|
}
|
|
|
|
|
) => ({
|
|
|
|
|
[`&.${classes.root}`]: {
|
2020-12-13 23:20:07 +01:00
|
|
|
display: 'flex'
|
|
|
|
|
},
|
2022-01-19 06:35:04 +04:00
|
|
|
|
|
|
|
|
[`& .${classes.drawer}`]: {
|
2020-12-13 23:20:07 +01:00
|
|
|
marginTop: '10em',
|
|
|
|
|
[theme.breakpoints.up('sm')]: {
|
|
|
|
|
width: drawerWidth,
|
|
|
|
|
flexShrink: 0
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-01-19 06:35:04 +04:00
|
|
|
|
|
|
|
|
[`& .${classes.appBar}`]: {
|
2020-12-13 23:20:07 +01:00
|
|
|
borderTop: '2px solid #303030',
|
2022-01-22 15:47:13 +04:00
|
|
|
marginTop: '3rem',
|
2020-12-13 23:20:07 +01:00
|
|
|
[theme.breakpoints.up('sm')]: {
|
|
|
|
|
width: `calc(100% - ${drawerWidth}px)`,
|
|
|
|
|
marginLeft: drawerWidth
|
2021-06-26 12:08:31 +02:00
|
|
|
},
|
|
|
|
|
zIndex: 1
|
2020-12-13 23:20:07 +01:00
|
|
|
},
|
2022-01-19 06:35:04 +04:00
|
|
|
|
|
|
|
|
[`& .${classes.menuButton}`]: {
|
2020-12-13 23:20:07 +01:00
|
|
|
[theme.breakpoints.up('sm')]: {
|
|
|
|
|
display: 'none'
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-01-19 06:35:04 +04:00
|
|
|
|
|
|
|
|
[`& .${classes.toolbar}`]: theme.mixins.toolbar,
|
|
|
|
|
|
|
|
|
|
[`& .${classes.drawerPaper}`]: {
|
2020-12-13 23:20:07 +01:00
|
|
|
borderTop: '2px solid #303030',
|
2022-01-22 15:47:13 +04:00
|
|
|
marginTop: '3rem',
|
2020-12-13 23:20:07 +01:00
|
|
|
width: drawerWidth
|
|
|
|
|
},
|
2022-01-19 06:35:04 +04:00
|
|
|
|
|
|
|
|
[`& .${classes.content}`]: {
|
2020-12-13 23:20:07 +01:00
|
|
|
flexGrow: 1,
|
2022-01-22 03:41:38 +04:00
|
|
|
padding: theme.spacing(1)
|
2020-12-13 23:20:07 +01:00
|
|
|
},
|
2022-01-19 06:35:04 +04:00
|
|
|
|
|
|
|
|
[`& .${classes.list}`]: {
|
2020-12-13 23:20:07 +01:00
|
|
|
marginBottom: '6em'
|
|
|
|
|
},
|
2022-01-19 06:35:04 +04:00
|
|
|
|
|
|
|
|
[`& .${classes.form}`]: {
|
2020-12-13 23:20:07 +01:00
|
|
|
marginLeft: theme.spacing(1)
|
|
|
|
|
},
|
2022-01-19 06:35:04 +04:00
|
|
|
|
|
|
|
|
[`& .${classes.koute}`]: {
|
2020-12-15 08:50:14 +01:00
|
|
|
position: 'absolute',
|
2021-06-05 21:23:31 +02:00
|
|
|
right: '40px',
|
2020-12-15 08:50:14 +01:00
|
|
|
top: '8px',
|
|
|
|
|
[theme.breakpoints.up('sm')]: {
|
|
|
|
|
top: '10px'
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-01-19 06:35:04 +04:00
|
|
|
|
|
|
|
|
[`& .${classes.vwe}`]: {
|
2020-12-15 08:50:14 +01:00
|
|
|
position: 'absolute',
|
2021-06-05 21:23:31 +02:00
|
|
|
right: '90px',
|
2020-12-15 08:50:14 +01:00
|
|
|
top: '8px',
|
|
|
|
|
[theme.breakpoints.up('sm')]: {
|
|
|
|
|
top: '10px'
|
|
|
|
|
}
|
2020-12-13 23:20:07 +01:00
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
|
2022-01-19 06:35:04 +04:00
|
|
|
const drawerWidth = 240
|
|
|
|
|
|
2021-06-26 12:32:44 +02:00
|
|
|
export default function TeksDrawer({teks, anTeks, komante}) {
|
2020-12-13 23:20:07 +01:00
|
|
|
const theme = useTheme()
|
2020-12-18 22:21:53 +01:00
|
|
|
const [esMobilOuve, meteEsMobilOuve] = useState(false)
|
2021-06-02 02:24:19 +02:00
|
|
|
const [open, setOpen] = useState(false)
|
|
|
|
|
const [error, setError] = useState('')
|
|
|
|
|
const [success, setSuccess] = useState('')
|
|
|
|
|
|
|
|
|
|
const handleClose = (event, reason) => {
|
|
|
|
|
if (reason === 'clickaway') {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setOpen(false)
|
|
|
|
|
setSuccess('')
|
|
|
|
|
setError('')
|
|
|
|
|
}
|
2020-12-13 23:20:07 +01:00
|
|
|
|
|
|
|
|
const handleDrawerToggle = () => {
|
2020-12-18 22:21:53 +01:00
|
|
|
meteEsMobilOuve(!esMobilOuve)
|
2020-12-13 23:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const container = typeof window === 'undefined' ? undefined : () => window.document.body
|
|
|
|
|
|
2021-06-02 02:24:19 +02:00
|
|
|
useEffect(() => {
|
|
|
|
|
if (error || success) {
|
|
|
|
|
setOpen(true)
|
|
|
|
|
}
|
|
|
|
|
}, [error, success, setOpen])
|
|
|
|
|
|
2020-12-13 23:20:07 +01:00
|
|
|
return (
|
2022-01-19 06:35:04 +04:00
|
|
|
<Root className={classes.root}>
|
2020-12-13 23:20:07 +01:00
|
|
|
<CssBaseline />
|
|
|
|
|
<AppBar position='fixed' className={classes.appBar}>
|
|
|
|
|
<Toolbar>
|
|
|
|
|
<IconButton
|
|
|
|
|
color='inherit'
|
|
|
|
|
aria-label='open drawer'
|
|
|
|
|
edge='start'
|
|
|
|
|
className={classes.menuButton}
|
2022-01-19 07:06:26 +04:00
|
|
|
size='large'
|
2020-12-13 23:20:07 +01:00
|
|
|
onClick={handleDrawerToggle}
|
|
|
|
|
>
|
|
|
|
|
<MenuIcon />
|
|
|
|
|
</IconButton>
|
2020-12-18 22:08:34 +01:00
|
|
|
{anTeks ? (
|
2020-12-13 23:20:07 +01:00
|
|
|
<>
|
2022-01-18 09:08:26 +04:00
|
|
|
<Link passHref href='/teks'>
|
2020-12-17 23:45:22 +01:00
|
|
|
<IconButton aria-label='return' size='medium'>
|
|
|
|
|
<KeyboardBackspaceIcon style={{fontSize: '1.5em'}} />
|
2020-12-13 23:20:07 +01:00
|
|
|
</IconButton>
|
|
|
|
|
</Link>
|
2020-12-18 22:08:34 +01:00
|
|
|
{anTeks.lyen && anTeks.lyen.length > 0 && (
|
2020-12-15 08:50:14 +01:00
|
|
|
<div className={classes.vwe}>
|
2020-12-18 22:08:34 +01:00
|
|
|
<VweKouteAchte niVideyo anTeks={anTeks} />
|
2020-12-15 08:50:14 +01:00
|
|
|
</div>
|
|
|
|
|
)}
|
2020-12-18 22:08:34 +01:00
|
|
|
{anTeks.kouteyAchtey && anTeks.kouteyAchtey.length > 0 && (
|
2020-12-15 08:50:14 +01:00
|
|
|
<div className={classes.koute}>
|
2020-12-18 22:08:34 +01:00
|
|
|
<VweKouteAchte niOdyo anTeks={anTeks} />
|
2020-12-15 08:50:14 +01:00
|
|
|
</div>
|
|
|
|
|
)}
|
2020-12-13 23:20:07 +01:00
|
|
|
</>
|
|
|
|
|
) : (
|
|
|
|
|
<Typography noWrap variant='h6'>
|
2022-01-27 22:51:49 +04:00
|
|
|
Derniers textes
|
2020-12-13 23:20:07 +01:00
|
|
|
</Typography>
|
|
|
|
|
)}
|
|
|
|
|
</Toolbar>
|
|
|
|
|
</AppBar>
|
|
|
|
|
<nav className={classes.drawer} aria-label='mailbox folders'>
|
|
|
|
|
<Hidden smUp implementation='css'>
|
|
|
|
|
<Drawer
|
|
|
|
|
container={container}
|
|
|
|
|
variant='temporary'
|
|
|
|
|
anchor={theme.direction === 'rtl' ? 'right' : 'left'}
|
2020-12-18 22:21:53 +01:00
|
|
|
open={esMobilOuve}
|
2020-12-13 23:20:07 +01:00
|
|
|
classes={{
|
|
|
|
|
paper: classes.drawerPaper
|
|
|
|
|
}}
|
|
|
|
|
ModalProps={{
|
|
|
|
|
keepMounted: true
|
|
|
|
|
}}
|
|
|
|
|
onClose={handleDrawerToggle}
|
|
|
|
|
>
|
2020-12-18 22:21:53 +01:00
|
|
|
<DrawerBar meteEsMobilOuve={meteEsMobilOuve} teks={teks} anTeks={anTeks} />
|
2020-12-13 23:20:07 +01:00
|
|
|
</Drawer>
|
|
|
|
|
</Hidden>
|
2022-01-19 07:06:26 +04:00
|
|
|
<Hidden smDown implementation='css'>
|
2020-12-13 23:20:07 +01:00
|
|
|
<Drawer
|
|
|
|
|
open
|
|
|
|
|
classes={{
|
|
|
|
|
paper: classes.drawerPaper
|
|
|
|
|
}}
|
|
|
|
|
variant='permanent'
|
|
|
|
|
>
|
2020-12-18 22:08:34 +01:00
|
|
|
<DrawerBar teks={teks} anTeks={anTeks} />
|
2020-12-13 23:20:07 +01:00
|
|
|
</Drawer>
|
|
|
|
|
</Hidden>
|
|
|
|
|
</nav>
|
|
|
|
|
<main className={classes.content}>
|
2020-12-18 22:08:34 +01:00
|
|
|
{anTeks ? (
|
2022-01-24 21:06:52 +04:00
|
|
|
<Teks
|
|
|
|
|
anTeks={anTeks}
|
|
|
|
|
komante={komante}
|
|
|
|
|
open={open}
|
|
|
|
|
success={success}
|
|
|
|
|
error={error}
|
|
|
|
|
setSuccess={setSuccess}
|
|
|
|
|
setError={setError}
|
|
|
|
|
handleClose={handleClose}
|
|
|
|
|
/>
|
2020-12-13 23:20:07 +01:00
|
|
|
) : (
|
2020-12-18 22:08:34 +01:00
|
|
|
<DenyeTeks {...teks} />
|
2020-12-13 23:20:07 +01:00
|
|
|
)}
|
|
|
|
|
</main>
|
2022-01-19 06:35:04 +04:00
|
|
|
</Root>
|
2020-12-13 23:20:07 +01:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TeksDrawer.propTypes = {
|
2020-12-18 22:08:34 +01:00
|
|
|
teks: PropTypes.array.isRequired,
|
2021-06-26 12:32:44 +02:00
|
|
|
anTeks: PropTypes.object,
|
|
|
|
|
komante: PropTypes.array
|
2020-12-13 23:20:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TeksDrawer.defaultProps = {
|
2021-06-26 12:32:44 +02:00
|
|
|
anTeks: null,
|
|
|
|
|
komante: null
|
2020-12-13 23:20:07 +01:00
|
|
|
}
|