aboutsummaryrefslogtreecommitdiffstats
path: root/src/views/Landing/CookiePermissionSnackbar.jsx
blob: e7867946bdb24fc26dcf4216443e10098c80fc71 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { Button, Snackbar } from '@mui/joy'
import Cookies from 'js-cookie'
import { useEffect, useState } from 'react'

const CookiePermissionSnackbar = () => {
  useEffect(() => {
    const cookiePermission = Cookies.get('cookies_permission')

    if (cookiePermission !== 'true') {
      setOpen(true)
    }
  }, [])

  const [open, setOpen] = useState(false)
  const handleClose = () => {
    // Cookies.set('cookies_permission', 'true')
    setOpen(false)
  }

  return (
    <Snackbar
      open={open}
      anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
      onClose={(event, reason) => {
        if (reason === 'clickaway') {
          return
        }
        // Cookies.set('cookies_permission', 'true')
        handleClose()
      }}
    >
      We use cookies to ensure you get the best experience on our website.
      <Button variant='soft' onClick={handleClose}>
        Accept
      </Button>
    </Snackbar>
  )
}

export default CookiePermissionSnackbar