diff --git a/components/cgu/cgu-dialog.js b/components/cgu/cgu-dialog.js new file mode 100644 index 0000000..3e79afe --- /dev/null +++ b/components/cgu/cgu-dialog.js @@ -0,0 +1,75 @@ +import React from 'react' +import PropTypes from 'prop-types' +import {Button, Dialog, DialogActions, DialogContent, DialogTitle, makeStyles, Typography} from '@material-ui/core' +import Cgu from '.' +import {useRouter} from 'next/router' + +const CGU_DOWNLOAD_LINK = process.env.NEXT_PUBLIC_CGU_DOWNLOAD_LINK + +const useStyles = makeStyles(() => ({ + dialog: { + zIndex: 9999 + } +})) + +export default function CGUDialog({open, setOpen}) { + const classes = useStyles() + const router = useRouter() + + const handleClose = () => { + setOpen(false) + } + + const handleDownload = event => { + event.preventDefault() + router.push(CGU_DOWNLOAD_LINK) + } + + const descriptionElementRef = React.useRef(null) + React.useEffect(() => { + if (open) { + const {current: descriptionElement} = descriptionElementRef + if (descriptionElement !== null) { + descriptionElement.focus() + } + } + }, [open]) + + return ( +
+ + CGU et politique de confidentialité + + + + + + + + + + +
+ ) +} + +CGUDialog.propTypes = { + open: PropTypes.bool.isRequired, + setOpen: PropTypes.func.isRequired +}