|
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 Banner from "components/Downbanner"; |
| 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 Banner from 'components/Banner'; |
13 | 13 |
|
14 | 14 | const queryClient = new QueryClient({ |
15 | | - defaultOptions: { |
16 | | - queries: { |
17 | | - retry: 0, |
18 | | - refetchOnWindowFocus: false, |
19 | | - // staleTime: 5000, // https://tkdodo.eu/blog/practical-react-query#the-defaults-explained |
| 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 | }, |
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 | | - }), |
| 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 | + }), |
31 | 31 | }); |
32 | 32 |
|
33 | 33 | declare global { |
34 | | - interface Window { |
35 | | - gtag?: ( |
36 | | - type: "event" | "config" | "get" | "set" | "consent", |
37 | | - action: "login" | "page_view", |
38 | | - options?: any |
39 | | - ) => void; |
40 | | - } |
| 34 | + interface Window { |
| 35 | + gtag?: ( |
| 36 | + type: 'event' | 'config' | 'get' | 'set' | 'consent', |
| 37 | + action: 'login' | 'page_view', |
| 38 | + options?: any |
| 39 | + ) => void; |
| 40 | + } |
41 | 41 | } |
42 | 42 |
|
43 | 43 | function App() { |
44 | | - const notistackRef = useRef<SnackbarProvider>(null); |
45 | | - useGetToken(); |
46 | | - useGoogleAnalytics(); |
| 44 | + const notistackRef = useRef<SnackbarProvider>(null); |
| 45 | + useGetToken(); |
| 46 | + useGoogleAnalytics(); |
47 | 47 |
|
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]); |
| 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]); |
56 | 56 |
|
57 | | - const handleCloseSnackbar = |
58 | | - (key: SnackbarKey) => (_event: React.MouseEvent) => { |
59 | | - if (notistackRef?.current?.closeSnackbar) |
60 | | - notistackRef.current?.closeSnackbar(key); |
| 57 | + const handleCloseSnackbar = (key: SnackbarKey) => (_event: React.MouseEvent) => { |
| 58 | + if (notistackRef?.current?.closeSnackbar) notistackRef.current?.closeSnackbar(key); |
61 | 59 | }; |
62 | 60 |
|
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 | | - <Banner /> |
75 | | - <Navbar /> |
76 | | - <BaseNavigation /> |
77 | | - </SnackbarProvider> |
78 | | - </QueryClientProvider> |
79 | | - ); |
| 61 | + return ( |
| 62 | + <QueryClientProvider client={queryClient}> |
| 63 | + <SnackbarProvider |
| 64 | + ref={notistackRef} |
| 65 | + autoHideDuration={8000} |
| 66 | + action={(key) => ( |
| 67 | + <IconButton onClick={handleCloseSnackbar(key)}> |
| 68 | + <Close sx={{ color: 'white' }} /> |
| 69 | + </IconButton> |
| 70 | + )} |
| 71 | + > |
| 72 | + <Banner /> |
| 73 | + <Navbar /> |
| 74 | + <BaseNavigation /> |
| 75 | + </SnackbarProvider> |
| 76 | + </QueryClientProvider> |
| 77 | + ); |
80 | 78 | } |
81 | 79 |
|
82 | 80 | export default App; |
0 commit comments