From 86a4bb97453066dcd641bbc114b1d7ccb8cccaa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20FAMIBELLE-PRONZOLA?= Date: Wed, 2 Jun 2021 02:24:19 +0200 Subject: [PATCH] Include Pataje to TeksDrawer --- components/teks/teks-drawer.js | 56 ++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/components/teks/teks-drawer.js b/components/teks/teks-drawer.js index 157cd2f..23d3ab4 100644 --- a/components/teks/teks-drawer.js +++ b/components/teks/teks-drawer.js @@ -1,4 +1,4 @@ -import {useState} from 'react' +import {useEffect, useState} from 'react' import PropTypes from 'prop-types' import Link from 'next/link' @@ -12,7 +12,8 @@ import { Hidden, IconButton, Box, - useMediaQuery + useMediaQuery, + Snackbar } from '@material-ui/core' import KeyboardBackspaceIcon from '@material-ui/icons/KeyboardBackspace' @@ -26,6 +27,13 @@ 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 @@ -96,6 +104,14 @@ const useStyles = makeStyles(theme => ({ [theme.breakpoints.up('sm')]: { top: '10px' } + }, + pataje: { + position: 'absolute', + top: '140px', + left: '10px', + [theme.breakpoints.up('sm')]: { + left: '275px' + } } })) @@ -149,6 +165,19 @@ export default function TeksDrawer({teks, 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) @@ -156,6 +185,12 @@ export default function TeksDrawer({teks, anTeks}) { const container = typeof window === 'undefined' ? undefined : () => window.document.body + useEffect(() => { + if (error || success) { + setOpen(true) + } + }, [error, success, setOpen]) + return (
@@ -234,6 +269,9 @@ export default function TeksDrawer({teks, anTeks}) { {anTeks.eksplisit && ( )} +
+ +
{anTeks.user && ( @@ -268,6 +306,20 @@ export default function TeksDrawer({teks, anTeks}) { ))} + {success && ( + + + {success} + + + )} + {error && ( + + + Une erreur s’est produite : {error.message} + + + )} ) : (