Added cookie notification
This commit is contained in:
@@ -24,7 +24,7 @@ This should get the template working in development mode.
|
|||||||
- ~~login (with cookies)~~
|
- ~~login (with cookies)~~
|
||||||
- ~~logout (with cookies)~~
|
- ~~logout (with cookies)~~
|
||||||
- ~~account deletion~~
|
- ~~account deletion~~
|
||||||
- annoying "This site uses cookies" message
|
- ~~annoying "This site uses cookies" message~~
|
||||||
- CSS template?
|
- CSS template?
|
||||||
- Administration Panel
|
- Administration Panel
|
||||||
- Exclusive to admin accounts
|
- Exclusive to admin accounts
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
//react
|
//react
|
||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import { BrowserRouter, Switch } from 'react-router-dom';
|
import { BrowserRouter, Switch } from 'react-router-dom';
|
||||||
|
import { useCookies } from 'react-cookie';
|
||||||
|
|
||||||
//library components
|
//library components
|
||||||
import LazyRoute from './lazy-route';
|
import LazyRoute from './lazy-route';
|
||||||
@@ -13,6 +14,25 @@ import Header from './panels/header.jsx';
|
|||||||
import Footer from './panels/footer.jsx';
|
import Footer from './panels/footer.jsx';
|
||||||
|
|
||||||
const App = props => {
|
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 (
|
return (
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<Header />
|
<Header />
|
||||||
|
|||||||
Reference in New Issue
Block a user