2021-09-21 21:28:04 +02:00
|
|
|
import {useRef, useEffect} from 'react'
|
2023-07-22 13:49:42 +04:00
|
|
|
import {styled, useTheme} from '@mui/material/styles'
|
2021-06-14 23:28:37 +02:00
|
|
|
import PropTypes from 'prop-types'
|
2022-01-19 07:06:26 +04:00
|
|
|
import {Button, Dialog, DialogActions, DialogContent, DialogTitle, Typography} from '@mui/material'
|
2023-07-22 13:36:33 +04:00
|
|
|
import {useRouter} from 'next/navigation'
|
2023-07-22 13:49:42 +04:00
|
|
|
import useMediaQuery from '@mui/material/useMediaQuery'
|
2021-09-21 21:28:04 +02:00
|
|
|
import Cgu from '.'
|
2021-06-14 23:28:37 +02:00
|
|
|
|
2022-01-19 06:35:04 +04:00
|
|
|
const PREFIX = 'cgu-dialog'
|
|
|
|
|
|
|
|
|
|
const classes = {
|
|
|
|
|
dialog: `${PREFIX}-dialog`
|
|
|
|
|
}
|
2021-06-14 23:28:37 +02:00
|
|
|
|
2022-01-19 06:35:04 +04:00
|
|
|
const Root = styled('div')(() => ({
|
|
|
|
|
[`& .${classes.dialog}`]: {
|
2023-07-22 13:49:42 +04:00
|
|
|
zIndex: 1
|
2021-06-14 23:28:37 +02:00
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
|
2022-01-19 06:35:04 +04:00
|
|
|
const CGU_DOWNLOAD_LINK = process.env.NEXT_PUBLIC_CGU_DOWNLOAD_LINK
|
|
|
|
|
|
2021-06-14 23:28:37 +02:00
|
|
|
export default function CGUDialog({open, setOpen}) {
|
2023-07-22 13:49:42 +04:00
|
|
|
const theme = useTheme()
|
|
|
|
|
const fullScreen = useMediaQuery(theme.breakpoints.down('md'))
|
2021-06-14 23:28:37 +02:00
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
|
|
const handleClose = () => {
|
|
|
|
|
setOpen(false)
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-15 20:19:34 +02:00
|
|
|
const handleClick = event => {
|
2021-06-14 23:28:37 +02:00
|
|
|
event.preventDefault()
|
|
|
|
|
router.push(CGU_DOWNLOAD_LINK)
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-21 21:28:04 +02:00
|
|
|
const descriptionElementRef = useRef(null)
|
|
|
|
|
useEffect(() => {
|
2021-06-14 23:28:37 +02:00
|
|
|
if (open) {
|
|
|
|
|
const {current: descriptionElement} = descriptionElementRef
|
|
|
|
|
if (descriptionElement !== null) {
|
|
|
|
|
descriptionElement.focus()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, [open])
|
|
|
|
|
|
|
|
|
|
return (
|
2022-01-19 06:35:04 +04:00
|
|
|
<Root>
|
2021-06-14 23:28:37 +02:00
|
|
|
<Dialog
|
2023-07-22 13:49:42 +04:00
|
|
|
fullScreen={fullScreen}
|
2021-06-14 23:28:37 +02:00
|
|
|
open={open}
|
|
|
|
|
scroll='paper'
|
|
|
|
|
aria-labelledby='scroll-dialog-title'
|
|
|
|
|
aria-describedby='scroll-dialog-description'
|
|
|
|
|
className={classes.dialog}
|
|
|
|
|
onClose={handleClose}
|
|
|
|
|
>
|
2023-07-22 13:49:42 +04:00
|
|
|
<DialogTitle className={classes.dialog} id='scroll-dialog-title'>CGU et politique de confidentialité</DialogTitle>
|
2021-06-14 23:28:37 +02:00
|
|
|
<DialogContent dividers>
|
|
|
|
|
<Typography
|
|
|
|
|
ref={descriptionElementRef}
|
2022-03-06 10:05:44 +04:00
|
|
|
component='div'
|
2021-06-14 23:28:37 +02:00
|
|
|
variant='inherit'
|
|
|
|
|
id='scroll-dialog-description'
|
|
|
|
|
tabIndex={-1}
|
|
|
|
|
>
|
|
|
|
|
<Cgu />
|
|
|
|
|
</Typography>
|
|
|
|
|
</DialogContent>
|
|
|
|
|
<DialogActions>
|
2021-06-15 20:19:34 +02:00
|
|
|
<Button color='primary' onClick={handleClick}>
|
|
|
|
|
Voir au format pdf
|
2021-06-14 23:28:37 +02:00
|
|
|
</Button>
|
|
|
|
|
<Button color='primary' onClick={handleClose}>
|
|
|
|
|
Fermer
|
|
|
|
|
</Button>
|
|
|
|
|
</DialogActions>
|
|
|
|
|
</Dialog>
|
2022-01-19 06:35:04 +04:00
|
|
|
</Root>
|
2021-06-14 23:28:37 +02:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CGUDialog.propTypes = {
|
|
|
|
|
open: PropTypes.bool.isRequired,
|
|
|
|
|
setOpen: PropTypes.func.isRequired
|
|
|
|
|
}
|