-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.jsx
65 lines (56 loc) · 2.85 KB
/
App.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import React, { useEffect, useState } from 'react';
import { Routes, Route } from "react-router-dom";
import { QueryClient, QueryClientProvider, useQuery } from 'react-query';
import CookieConsent, { getCookieConsentValue } from "react-cookie-consent";
import usePageTracking from './hooks/usePageTracking';
import CollectionView from "./components/CollectionView";
import ItemView from "./components/ItemView";
import { useLocation } from 'react-router-dom'
import { GridCollection, JSONItem, WordCloudItem } from "./renderers";
import NarrationsThumbnail from "./custom/NarrationsThumbnail";
import NarrationsItem from "./custom/NarrationsItem";
import LoginView from "./components/LoginView";
import "normalize.css/normalize.css";
import "@blueprintjs/icons/lib/css/blueprint-icons.css";
import "@blueprintjs/core/lib/css/blueprint.css";
import "./App.scss";
import "./custom.scss";
const COOKIE_NAME = "ganalytics_cookie_consent"
const queryClient = new QueryClient();
function PageAnalytics() {
usePageTracking();
return <></>
}
export default function App() {
const [cookiesAccepted, setCookiesAccepted] = useState(getCookieConsentValue(COOKIE_NAME));
const location = useLocation();
const showCookieConsent = location.pathname !== '/login';
return (
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/login" element={<LoginView />} />
<Route path="/:id" element={<ItemView itemRenderer={NarrationsItem} allowReview={false} />} />
<Route path="/" element={<CollectionView
collectionRenderer={GridCollection}
// itemRenderer={JSONItem}
itemRenderer={NarrationsThumbnail}
/>} />
</Routes>
{/* Cookie Policy and GAnalytics */}
{cookiesAccepted && <PageAnalytics />}
{showCookieConsent &&
<CookieConsent
location="bottom"
buttonText="Accept and Close"
cookieName={COOKIE_NAME}
style={{ background: '#7762ce', width: '100%', left: 'auto', position: 'fixed' }}
buttonStyle={{ background: "#fff", fontSize: "13px" }}
onAccept={() => setCookiesAccepted(true)}>
We use Google Analytics to understand page use and develop this website. To learn more, see <a href="https://developers.google.com/analytics/devguides/collection/gtagjs/cookie-usage" style={{ color: 'rgb(86 191 255)' }}>here</a>.
<br />
To opt out of being tracked via Google Analytics, you can also use Google's opt-out browser add-on <a href="https://tools.google.com/dlpage/gaoptout" style={{ color: 'rgb(86 191 255)' }}>here</a>.
</CookieConsent>
}
</QueryClientProvider>
);
}