Added cookie notification
This commit is contained in:
@@ -24,7 +24,7 @@ This should get the template working in development mode.
|
||||
- ~~login (with cookies)~~
|
||||
- ~~logout (with cookies)~~
|
||||
- ~~account deletion~~
|
||||
- annoying "This site uses cookies" message
|
||||
- ~~annoying "This site uses cookies" message~~
|
||||
- CSS template?
|
||||
- Administration Panel
|
||||
- Exclusive to admin accounts
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//react
|
||||
import React from 'react';
|
||||
import React, { useState } from 'react';
|
||||
import { BrowserRouter, Switch } from 'react-router-dom';
|
||||
import { useCookies } from 'react-cookie';
|
||||
|
||||
//library components
|
||||
import LazyRoute from './lazy-route';
|
||||
@@ -13,6 +14,25 @@ import Header from './panels/header.jsx';
|
||||
import Footer from './panels/footer.jsx';
|
||||
|
||||
const App = props => {
|
||||
//handle cookies prompt
|
||||
const [cookies, setCookie] = useCookies();
|
||||
|
||||
if (!cookies['accept-cookies']) {
|
||||
const accept = confirm('This website uses cookies to operate correctly. By clicking "ok", you agree to accept said cookies.');
|
||||
|
||||
if (accept) {
|
||||
setCookie('accept-cookies', true);
|
||||
} else {
|
||||
return (
|
||||
<div>
|
||||
<p>This website won't operate correctly without cookies.</p>
|
||||
<button onClick={() => window.location.reload()}>Reload Page</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//default render
|
||||
return (
|
||||
<BrowserRouter>
|
||||
<Header />
|
||||
|
||||
Reference in New Issue
Block a user