11import React , { useContext } from 'react' ;
2- import { graphql , useStaticQuery , navigate } from 'gatsby' ;
2+ import { graphql , navigate , useStaticQuery } from 'gatsby' ;
33import { CssBaseline } from '@mui/material' ;
44import Alert from '@mui/material/Alert' ;
55import { createTheme , ThemeProvider } from '@mui/material/styles' ;
66import Button from '@mui/material/Button' ;
77import Typography from '@mui/material/Typography' ;
8+ import Dialog from '@mui/material/Dialog' ;
9+ import DialogActions from '@mui/material/DialogActions' ;
10+ import DialogContent from '@mui/material/DialogContent' ;
11+ import DialogContentText from '@mui/material/DialogContentText' ;
12+ import DialogTitle from '@mui/material/DialogTitle' ;
813import DefaultAppBar from '../DefaultAppBar' ;
914import Footer from '../Footer' ;
1015import { MainContext } from '../../contexts/MainContextProvider' ;
1116import ThemeSelector from '../../utils/ThemeSelector' ;
1217import './index.css' ;
13- import { setHasAcceptedCookieNotice } from '../../reducers/MainReducer/Actions' ;
18+ import { disableV2Notice , setHasAcceptedCookieNotice } from '../../reducers/MainReducer/Actions' ;
1419
1520const Layout = ( { children } ) => {
1621 const [ state , dispatch ] = useContext ( MainContext ) ;
17- const { themeIndex, themeColorIndex, hasAcceptedCookieNotice } = state ;
22+ const {
23+ themeIndex, themeColorIndex, hasAcceptedCookieNotice, hasTriedVersion2,
24+ } = state ;
1825 const data = useStaticQuery ( graphql `query {
1926 site {
2027 siteMetadata {
@@ -41,15 +48,29 @@ const Layout = ({ children }) => {
4148 } ) ;
4249
4350 /**
44- * Accept cookies
51+ * Accept the cookie notice
4552 */
4653 const acceptCookies = ( ) => {
4754 dispatch ( setHasAcceptedCookieNotice ( true ) ) ;
4855 } ;
4956
5057 /**
51- * Go to the GDPR site
58+ * Disable the new version of the site
5259 */
60+ const disableV2 = ( ) => {
61+ dispatch ( disableV2Notice ( ) ) ;
62+ } ;
63+
64+ /**
65+ * Go to the new version of the site
66+ */
67+ const tryV2 = ( ) => {
68+ window . location . href = window . location . href . replace ( 'codedead.com' , 'v2.codedead.com' ) ;
69+ } ;
70+
71+ /**
72+ * Go to the GDPR site
73+ */
5374 const gotoGdpr = ( ) => {
5475 navigate ( 'https://commission.europa.eu/resources-partners/europa-web-guide_en' ) ;
5576 } ;
@@ -59,6 +80,35 @@ const Layout = ({ children }) => {
5980 < CssBaseline />
6081 < DefaultAppBar title = { data . site . siteMetadata . title } />
6182 { children }
83+ { ! hasTriedVersion2 ? (
84+ < Dialog
85+ open = { ! hasTriedVersion2 }
86+ onClose = { disableV2 }
87+ aria-labelledby = "v2-alert-dialog-title"
88+ aria-describedby = "v2-alert-dialog-description"
89+ >
90+ < DialogTitle id = "alert-dialog-title" >
91+ New website design!
92+ </ DialogTitle >
93+ < DialogContent >
94+ < DialogContentText id = "v2-alert-dialog-description" >
95+ We're redesigning our website to make it more user-friendly
96+ and visually appealing.
97+
98+ Keep in mind that this is still a work in progress and some
99+ features may not be available yet.
100+
101+ Would you like to try the new design?
102+ </ DialogContentText >
103+ </ DialogContent >
104+ < DialogActions >
105+ < Button onClick = { disableV2 } > No</ Button >
106+ < Button onClick = { tryV2 } autoFocus >
107+ Yes please!
108+ </ Button >
109+ </ DialogActions >
110+ </ Dialog >
111+ ) : null }
62112 { hasAcceptedCookieNotice ? null : (
63113 < Alert
64114 severity = "warning"
0 commit comments