From 40f76779f78cf1d9cff74c07d21e3f429b6ee7e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20FAMIBELLE-PRONZOLA?= Date: Sat, 26 Jun 2021 12:27:48 +0200 Subject: [PATCH] Create VweKomante component --- components/komante/vwe-komante.js | 136 ++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 components/komante/vwe-komante.js diff --git a/components/komante/vwe-komante.js b/components/komante/vwe-komante.js new file mode 100644 index 0000000..a6b1d88 --- /dev/null +++ b/components/komante/vwe-komante.js @@ -0,0 +1,136 @@ +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 +}