diff --git a/components/jwenn-sesyon/sesyon-dialog.js b/components/jwenn-sesyon/sesyon-dialog.js new file mode 100644 index 0000000..e98ba21 --- /dev/null +++ b/components/jwenn-sesyon/sesyon-dialog.js @@ -0,0 +1,208 @@ +import React, {useEffect, useState} from 'react' +import Image from 'next/image' +import PropTypes from 'prop-types' +import {withStyles} from '@material-ui/core/styles' +import {Box, Button, Divider, Snackbar, useMediaQuery, Link, Dialog} from '@material-ui/core' +import MuiDialogTitle from '@material-ui/core/DialogTitle' +import MuiDialogContent from '@material-ui/core/DialogContent' +import IconButton from '@material-ui/core/IconButton' +import CloseIcon from '@material-ui/icons/Close' +import Typography from '@material-ui/core/Typography' +import MuiAlert from '@material-ui/lab/Alert' +import FileCopyIcon from '@material-ui/icons/FileCopy' +import AndroidIcon from '@material-ui/icons/Android' +import AppleIcon from '@material-ui/icons/Apple' +import GetAppIcon from '@material-ui/icons/GetApp' +import {Windows, Linux} from '@icons-pack/react-simple-icons' + +const sessionUrl = process.env.NEXT_PUBLIC_SESSION_URL || 'http://sesyon.o-k-i.net' + +function Alert(props) { + return +} + +const styles = theme => ({ + root: { + margin: 0, + padding: theme.spacing(2) + }, + closeButton: { + position: 'absolute', + right: theme.spacing(1), + top: theme.spacing(1), + color: theme.palette.grey[500] + } +}) + +const DialogTitle = withStyles(styles)(props => { + const {children, classes, onClose, ...other} = props + return ( + + {children} + {onClose ? ( + + + + ) : null} + + ) +}) + +const DialogContent = withStyles(theme => ({ + root: { + padding: theme.spacing(2) + } +}))(MuiDialogContent) + +export default function SesyonDialog({ouve, handleFemen}) { + const isMobile = useMediaQuery('(max-width:800px)') + const [error, setError] = useState('') + const [success, setSuccess] = useState('') + const [ouveSnack, meteOuveSnack] = useState(false) + + const handleFemenSnack = (event, reason) => { + if (reason === 'clickaway') { + return + } + + meteOuveSnack(false) + setSuccess('') + setError('') + } + + const handleCopyUrl = () => { + if (typeof window !== 'undefined') { + navigator.clipboard.writeText(sessionUrl) + .then( + () => setSuccess('URL copiée avec succès'), + () => setError('Error lors de la copie du lien') + ) + } + + meteOuveSnack(false) + } + + useEffect(() => { + if (error || success) { + meteOuveSnack(true) + } + }, [error, success, meteOuveSnack]) + + return ( +
+ + + Nous rejoindre + + + + Télécharger l’application + + + + + Mobile + + + Ordinateur + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Rejoindre le groupe public + + + + + + + + + + {success && ( + + + {success} + + + )} + {error && ( + + + Une erreur s’est produite : {error.message} + + + )} +
+ ) +} + +SesyonDialog.propTypes = { + ouve: PropTypes.bool.isRequired, + handleFemen: PropTypes.func.isRequired +}