1- import React , { useEffect , useContext , Suspense , lazy , useState } from "react" ;
1+ import React , { useEffect , useContext , Suspense , lazy } from "react" ;
22import HeaderBar from "../HeaderBar" ;
33import { Center , Loader , useMantineColorScheme } from "@mantine/core" ;
44import { AppShell } from "@mantine/core" ;
55import { BrowserRouter , Routes , Route } from "react-router-dom" ;
66import Footer from "../Footer/index.jsx" ;
77import { MainContext } from "../../context/MainContextProvider" ;
8- import ReactGA from "react-ga4" ;
9- import { setAllowCookies } from "../../reducer/MainReducer/Actions/index.js" ;
10- import CookieNotice from "../CookieNotice/index.jsx" ;
118
129const Home = lazy ( ( ) => import ( "../../routes/Home" ) ) ;
1310const About = lazy ( ( ) => import ( "../../routes/About" ) ) ;
1411const NotFound = lazy ( ( ) => import ( "../../routes/NotFound" ) ) ;
1512
1613const App = ( ) => {
17- const [ state , d1 ] = useContext ( MainContext ) ;
14+ const [ state ] = useContext ( MainContext ) ;
1815 const { setColorScheme } = useMantineColorScheme ( ) ;
1916
20- const { themeType, allowCookies, hasSetCookies } = state ;
21-
22- const [ cookieBannerOpen , setCookieBannerOpen ] = useState ( ! hasSetCookies ) ;
23-
24- /**
25- * Close the cookie banner
26- */
27- const closeCookieBanner = ( ) => {
28- setCookieBannerOpen ( false ) ;
29- } ;
30-
31- /**
32- * Accept cookies
33- */
34- const acceptCookies = ( ) => {
35- d1 ( setAllowCookies ( true ) ) ;
36- setCookieBannerOpen ( false ) ;
37- } ;
38-
39- /**
40- * Decline cookies
41- */
42- const declineCookies = ( ) => {
43- d1 ( setAllowCookies ( false ) ) ;
44- setCookieBannerOpen ( false ) ;
45- } ;
17+ const { themeType } = state ;
4618
4719 useEffect ( ( ) => {
4820 setColorScheme ( themeType ) ;
4921 } , [ ] ) ;
5022
51- useEffect ( ( ) => {
52- if ( allowCookies ) {
53- ReactGA . initialize ( "G-YQZGPHN1BH" ) ;
54- window [ "ga-disable-G-YQZGPHN1BH" ] = false ;
55- } else {
56- window [ "ga-disable-G-YQZGPHN1BH" ] = true ;
57- }
58- } , [ allowCookies ] ) ;
59-
6023 return (
6124 < BrowserRouter >
62- < AppShell
63- header = { { height : 60 } }
64- footer = { { height : 115 } }
65- padding = "md"
66- >
25+ < AppShell header = { { height : 60 } } footer = { { height : 115 } } padding = "md" >
6726 < AppShell . Header >
6827 < HeaderBar />
6928 </ AppShell . Header >
@@ -82,13 +41,6 @@ const App = () => {
8241 </ Routes >
8342 </ Suspense >
8443 </ AppShell . Main >
85- { cookieBannerOpen ? (
86- < CookieNotice
87- onAccept = { acceptCookies }
88- onDecline = { declineCookies }
89- onClose = { closeCookieBanner }
90- />
91- ) : null }
9244 < AppShell . Footer >
9345 < Footer />
9446 </ AppShell . Footer >
0 commit comments