import {useEffect, useState} from 'react'
import PropTypes from 'prop-types'
import Link from 'next/link'
import {
Grid,
Toolbar,
Typography,
AppBar,
CssBaseline,
Drawer,
Hidden,
IconButton,
Box,
useMediaQuery,
Snackbar
} from '@material-ui/core'
import KeyboardBackspaceIcon from '@material-ui/icons/KeyboardBackspace'
import ExplicitIcon from '@material-ui/icons/Explicit'
import MenuIcon from '@material-ui/icons/Menu'
import {makeStyles, useTheme} from '@material-ui/core/styles'
import {formatJsonString} from '../../lib/utils/format'
import DrawerBar from './drawer-bar'
import DenyeTeks from './denye-teks'
import VweKouteAchte from './vwe-koute-achte'
import OkiMizik from './oki-mizik'
import Pataje from './pataje'
import MuiAlert from '@material-ui/lab/Alert'
function Alert(props) {
return
}
const drawerWidth = 240
const useStyles = makeStyles(theme => ({
root: {
display: 'flex'
},
drawer: {
marginTop: '10em',
[theme.breakpoints.up('sm')]: {
width: drawerWidth,
flexShrink: 0
}
},
appBar: {
borderTop: '2px solid #303030',
marginTop: '4.71rem',
[theme.breakpoints.up('sm')]: {
width: `calc(100% - ${drawerWidth}px)`,
marginLeft: drawerWidth
},
zIndex: 1
},
menuButton: {
[theme.breakpoints.up('sm')]: {
display: 'none'
}
},
toolbar: theme.mixins.toolbar,
drawerPaper: {
borderTop: '2px solid #303030',
marginTop: '4.71rem',
width: drawerWidth
},
content: {
flexGrow: 1,
padding: theme.spacing(3)
},
list: {
marginBottom: '6em'
},
form: {
marginLeft: theme.spacing(1)
},
text: {
marginBottom: '0.5em'
},
gridText: {
border: '2px solid grey',
borderRadius: '5px',
marginTop: '2em',
padding: '1em'
},
grid: {
marginTop: '1em'
},
koute: {
position: 'absolute',
right: '40px',
top: '8px',
[theme.breakpoints.up('sm')]: {
top: '10px'
}
},
vwe: {
position: 'absolute',
right: '90px',
top: '8px',
[theme.breakpoints.up('sm')]: {
top: '10px'
}
},
pataje: {
position: 'fixed',
top: '85px',
left: '110px',
zIndex: 2,
[theme.breakpoints.up('sm')]: {
top: '88px',
left: '340px'
}
}
}))
const langToArray = anTeks => {
const langArray = []
if (anTeks && anTeks.tradiksyon) {
const {francais, english, espagnol} = anTeks.tradiksyon
if (francais) {
langArray.push({title: 'Traduction', emoji: '🇫🇷', lang: francais})
}
if (english) {
langArray.push({title: 'Translation', emoji: '🇬🇧', lang: english})
}
if (espagnol) {
langArray.push({title: 'Traducción', emoji: '🇪🇸', lang: espagnol})
}
}
return langArray
}
const alignTeks = (langArray, isMobile) => {
if (langArray.length > 0 && !isMobile) {
return 'justify'
}
if (langArray.length > 0 && isMobile) {
return 'justify'
}
if (langArray.length === 0 && isMobile) {
return 'justify'
}
if (langArray.length === 0 && !isMobile) {
return 'center'
}
}
export default function TeksDrawer({teks, anTeks}) {
const isMobile = useMediaQuery('(max-width:800px)')
const langArray = langToArray(anTeks)
const classes = useStyles()
const theme = useTheme()
const [esMobilOuve, meteEsMobilOuve] = useState(false)
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('')
}
const handleDrawerToggle = () => {
meteEsMobilOuve(!esMobilOuve)
}
const container = typeof window === 'undefined' ? undefined : () => window.document.body
useEffect(() => {
if (error || success) {
setOpen(true)
}
}, [error, success, setOpen])
return (
{anTeks ? (
<>
{anTeks.lyen && anTeks.lyen.length > 0 && (
)}
{anTeks.kouteyAchtey && anTeks.kouteyAchtey.length > 0 && (
)}
>
) : (
Dènyé Tèks
)}
{anTeks ? (
<>
{anTeks.tit}
{anTeks.eksplisit && (
)}
{anTeks.user && (
texte soumis par {anTeks.user.username}
)}
{anTeks.okiMizikID && (
)}
0 ? 6 : null}>
Transcription
{formatJsonString(anTeks.transkripsyon)}
{langArray.map(({title, emoji, lang}) => (
{title}
{formatJsonString(lang)}
))}
{success && (
{success}
)}
{error && (
Une erreur s’est produite : {error.message}
)}
>
) : (
)}
)
}
TeksDrawer.propTypes = {
teks: PropTypes.array.isRequired,
anTeks: PropTypes.object
}
TeksDrawer.defaultProps = {
anTeks: null
}