|
1 | | -import Close from '@mui/icons-material/Close'; |
2 | | -import { IconButton } from '@mui/material'; |
3 | | -import { AxiosError } from 'axios'; |
4 | | -import useGoogleAnalytics from 'hooks/useGoogleAnalytics'; |
5 | | -import { SnackbarKey, SnackbarProvider } from 'notistack'; |
6 | | -import { useEffect, useRef } from 'react'; |
7 | | -import { QueryCache, QueryClient, QueryClientProvider } from 'react-query'; |
8 | | -import Navbar from 'components/Navbar/Navbar'; |
9 | | -import useGetToken from './hooks/useGetToken'; |
10 | | -import BaseNavigation from 'pages/BaseNavigation/BaseNavigation'; |
11 | | -import { useLocation } from 'react-router-dom'; |
| 1 | +import Close from "@mui/icons-material/Close"; |
| 2 | +import { IconButton } from "@mui/material"; |
| 3 | +import { AxiosError } from "axios"; |
| 4 | +import useGoogleAnalytics from "hooks/useGoogleAnalytics"; |
| 5 | +import { SnackbarKey, SnackbarProvider } from "notistack"; |
| 6 | +import { useEffect, useRef } from "react"; |
| 7 | +import { QueryCache, QueryClient, QueryClientProvider } from "react-query"; |
| 8 | +import Navbar from "components/Navbar/Navbar"; |
| 9 | +import useGetToken from "./hooks/useGetToken"; |
| 10 | +import BaseNavigation from "pages/BaseNavigation/BaseNavigation"; |
| 11 | +import { useLocation } from "react-router-dom"; |
| 12 | +import Downbanner from "components/Downbanner"; |
12 | 13 |
|
13 | 14 | const queryClient = new QueryClient({ |
14 | | - defaultOptions: { |
15 | | - queries: { |
16 | | - retry: 0, |
17 | | - refetchOnWindowFocus: false, |
18 | | - // staleTime: 5000, // https://tkdodo.eu/blog/practical-react-query#the-defaults-explained |
19 | | - }, |
| 15 | + defaultOptions: { |
| 16 | + queries: { |
| 17 | + retry: 0, |
| 18 | + refetchOnWindowFocus: false, |
| 19 | + // staleTime: 5000, // https://tkdodo.eu/blog/practical-react-query#the-defaults-explained |
20 | 20 | }, |
21 | | - queryCache: new QueryCache({ |
22 | | - onError: (error) => { |
23 | | - console.log({ error }); |
24 | | - const responseStatus = (error as AxiosError)?.response?.status; |
25 | | - if (responseStatus && responseStatus === 404) { |
26 | | - console.error('could not find resource'); |
27 | | - } |
28 | | - }, |
29 | | - }), |
| 21 | + }, |
| 22 | + queryCache: new QueryCache({ |
| 23 | + onError: (error) => { |
| 24 | + console.log({ error }); |
| 25 | + const responseStatus = (error as AxiosError)?.response?.status; |
| 26 | + if (responseStatus && responseStatus === 404) { |
| 27 | + console.error("could not find resource"); |
| 28 | + } |
| 29 | + }, |
| 30 | + }), |
30 | 31 | }); |
31 | 32 |
|
32 | 33 | declare global { |
33 | | - interface Window { |
34 | | - gtag?: ( |
35 | | - type: 'event' | 'config' | 'get' | 'set' | 'consent', |
36 | | - action: 'login' | 'page_view', |
37 | | - options?: any |
38 | | - ) => void; |
39 | | - } |
| 34 | + interface Window { |
| 35 | + gtag?: ( |
| 36 | + type: "event" | "config" | "get" | "set" | "consent", |
| 37 | + action: "login" | "page_view", |
| 38 | + options?: any |
| 39 | + ) => void; |
| 40 | + } |
40 | 41 | } |
41 | 42 |
|
42 | 43 | function App() { |
43 | | - const notistackRef = useRef<SnackbarProvider>(null); |
44 | | - useGetToken(); |
45 | | - useGoogleAnalytics(); |
| 44 | + const notistackRef = useRef<SnackbarProvider>(null); |
| 45 | + useGetToken(); |
| 46 | + useGoogleAnalytics(); |
46 | 47 |
|
47 | | - const location = useLocation(); |
48 | | - useEffect(() => { |
49 | | - if (window.gtag) { |
50 | | - window.gtag('event', 'page_view', { |
51 | | - page_path: `${location.pathname}${location.search}`, |
52 | | - }); |
53 | | - } |
54 | | - }, [location]); |
| 48 | + const location = useLocation(); |
| 49 | + useEffect(() => { |
| 50 | + if (window.gtag) { |
| 51 | + window.gtag("event", "page_view", { |
| 52 | + page_path: `${location.pathname}${location.search}`, |
| 53 | + }); |
| 54 | + } |
| 55 | + }, [location]); |
55 | 56 |
|
56 | | - const handleCloseSnackbar = (key: SnackbarKey) => (_event: React.MouseEvent) => { |
57 | | - if (notistackRef?.current?.closeSnackbar) notistackRef.current?.closeSnackbar(key); |
| 57 | + const handleCloseSnackbar = |
| 58 | + (key: SnackbarKey) => (_event: React.MouseEvent) => { |
| 59 | + if (notistackRef?.current?.closeSnackbar) |
| 60 | + notistackRef.current?.closeSnackbar(key); |
58 | 61 | }; |
59 | 62 |
|
60 | | - return ( |
61 | | - <QueryClientProvider client={queryClient}> |
62 | | - <SnackbarProvider |
63 | | - ref={notistackRef} |
64 | | - autoHideDuration={8000} |
65 | | - action={(key) => ( |
66 | | - <IconButton onClick={handleCloseSnackbar(key)}> |
67 | | - <Close sx={{ color: 'white' }} /> |
68 | | - </IconButton> |
69 | | - )} |
70 | | - > |
71 | | - <Navbar /> |
72 | | - <BaseNavigation /> |
73 | | - </SnackbarProvider> |
74 | | - </QueryClientProvider> |
75 | | - ); |
| 63 | + return ( |
| 64 | + <QueryClientProvider client={queryClient}> |
| 65 | + <SnackbarProvider |
| 66 | + ref={notistackRef} |
| 67 | + autoHideDuration={8000} |
| 68 | + action={(key) => ( |
| 69 | + <IconButton onClick={handleCloseSnackbar(key)}> |
| 70 | + <Close sx={{ color: "white" }} /> |
| 71 | + </IconButton> |
| 72 | + )} |
| 73 | + > |
| 74 | + <Downbanner /> |
| 75 | + <Navbar /> |
| 76 | + <BaseNavigation /> |
| 77 | + </SnackbarProvider> |
| 78 | + </QueryClientProvider> |
| 79 | + ); |
76 | 80 | } |
77 | 81 |
|
78 | 82 | export default App; |
0 commit comments