From 97ed7c543373dead816a7d20c90761a1f7a1a7c1 Mon Sep 17 00:00:00 2001 From: CodeDead Date: Tue, 2 Feb 2021 16:42:50 +0100 Subject: [PATCH] * Added a cookie notice --- package.json | 1 + src/components/Layout/index.jsx | 52 +++++++++++++++++-- src/contexts/MainContextProvider/index.jsx | 2 + .../MainReducer/Actions/actionTypes.js | 1 + src/reducers/MainReducer/Actions/index.js | 9 +++- src/reducers/MainReducer/index.jsx | 7 +++ yarn.lock | 22 ++++++++ 7 files changed, 89 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index bae5e63..d265ca4 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "dependencies": { "@material-ui/core": "^4.11.3", "@material-ui/icons": "^4.11.2", + "@material-ui/lab": "^4.0.0-alpha.57", "gatsby": "^2.31.1", "gatsby-image": "^2.10.0", "gatsby-plugin-google-gtag": "^2.7.0", diff --git a/src/components/Layout/index.jsx b/src/components/Layout/index.jsx index 2114f55..0f5e01e 100644 --- a/src/components/Layout/index.jsx +++ b/src/components/Layout/index.jsx @@ -1,16 +1,20 @@ import React, { useContext } from 'react'; -import { graphql, useStaticQuery } from 'gatsby'; +import { graphql, useStaticQuery, navigate } from 'gatsby'; import { CssBaseline } from '@material-ui/core'; +import Alert from '@material-ui/lab/Alert'; import { createMuiTheme, ThemeProvider } from '@material-ui/core/styles'; +import Button from '@material-ui/core/Button'; +import Typography from '@material-ui/core/Typography'; import DefaultAppBar from '../DefaultAppBar'; import Footer from '../Footer'; import { MainContext } from '../../contexts/MainContextProvider'; import ThemeSelector from '../../utils/ThemeSelector'; import './index.css'; +import { setHasAcceptedCookieNotice } from '../../reducers/MainReducer/Actions'; const Layout = ({ children }) => { - const [state] = useContext(MainContext); - const { themeIndex, themeColorIndex } = state; + const [state, dispatch] = useContext(MainContext); + const { themeIndex, themeColorIndex, hasAcceptedCookieNotice } = state; const data = useStaticQuery(graphql`query { site { siteMetadata { @@ -37,11 +41,53 @@ const Layout = ({ children }) => { }, }); + /** + * Accept cookies + */ + const acceptCookies = () => { + dispatch(setHasAcceptedCookieNotice(true)); + }; + + /** + * Go to the GDPR site + */ + const gotoGdpr = () => { + navigate('http://ec.europa.eu/ipg/basics/legal/cookies/index_en.htm'); + }; + return ( {children} + {hasAcceptedCookieNotice ? null : ( + + + We might use cookies to ensure that we give you the best experience on our website. + If you continue to use this site we will assume that you are happy with it. + + + + + + + )}