import {useState, useEffect, useRef} from 'react' import PropTypes from 'prop-types' import {useSession} from 'next-auth/client' import Koneksyon from '../sesyon/koneksyon' import { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button, Typography, Tooltip, Zoom, withStyles, makeStyles } from '@material-ui/core' import AddCommentIcon from '@material-ui/icons/AddComment' import KomanteList from './komante-list' import {useRouter} from 'next/router' import EkriKomante from './ekri-komante' const useStyles = makeStyles(theme => ({ margin: { margin: theme.spacing(1) }, extendedIcon: { marginRight: theme.spacing(1) } })) const KomanteTooltip = withStyles(() => ({ tooltip: { fontSize: 18 } }))(Tooltip) export default function VweKomante({komante, teks}) { const classes = useStyles() const [esOuve, meteEsOuve] = useState(false) const [esKoneksyonOuve, meteEsKoneksyonOuve] = useState(false) const [esKomenteOuve, meteEsKomanteOuve] = useState(false) const [session] = useSession() const router = useRouter() const handleClick = () => { meteEsOuve(true) } const handleClose = () => { meteEsOuve(false) } const descriptionElementRef = useRef(null) useEffect(() => { if (esOuve) { const {current: descriptionElement} = descriptionElementRef if (descriptionElement !== null) { descriptionElement.focus() } } }, [esOuve]) return ( <> Kòmantè {komante.length > 0 ? ( ) : ( Aucun )} {session && session.user && !esKomenteOuve && ( )} {!session && !esKoneksyonOuve && ( )} {!session && esKoneksyonOuve && ( )} {!session && esKoneksyonOuve && ( )} {session && session.user && esKomenteOuve && ( <> )} ) } VweKomante.defaultProps = { komante: null } VweKomante.propTypes = { komante: PropTypes.array, teks: PropTypes.object.isRequired }