Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maint 853 update baner with new townhall link #857

Merged
merged 6 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 64 additions & 66 deletions compose/neurosynth-frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,82 +1,80 @@
import Close from "@mui/icons-material/Close";
import { IconButton } from "@mui/material";
import { AxiosError } from "axios";
import useGoogleAnalytics from "hooks/useGoogleAnalytics";
import { SnackbarKey, SnackbarProvider } from "notistack";
import { useEffect, useRef } from "react";
import { QueryCache, QueryClient, QueryClientProvider } from "react-query";
import Navbar from "components/Navbar/Navbar";
import useGetToken from "./hooks/useGetToken";
import BaseNavigation from "pages/BaseNavigation/BaseNavigation";
import { useLocation } from "react-router-dom";
import Banner from "components/Downbanner";
import Close from '@mui/icons-material/Close';
import { IconButton } from '@mui/material';
import { AxiosError } from 'axios';
import useGoogleAnalytics from 'hooks/useGoogleAnalytics';
import { SnackbarKey, SnackbarProvider } from 'notistack';
import { useEffect, useRef } from 'react';
import { QueryCache, QueryClient, QueryClientProvider } from 'react-query';
import Navbar from 'components/Navbar/Navbar';
import useGetToken from './hooks/useGetToken';
import BaseNavigation from 'pages/BaseNavigation/BaseNavigation';
import { useLocation } from 'react-router-dom';
import Banner from 'components/Banner';

const queryClient = new QueryClient({
defaultOptions: {
queries: {
retry: 0,
refetchOnWindowFocus: false,
// staleTime: 5000, // https://tkdodo.eu/blog/practical-react-query#the-defaults-explained
defaultOptions: {
queries: {
retry: 0,
refetchOnWindowFocus: false,
// staleTime: 5000, // https://tkdodo.eu/blog/practical-react-query#the-defaults-explained
},
},
},
queryCache: new QueryCache({
onError: (error) => {
console.log({ error });
const responseStatus = (error as AxiosError)?.response?.status;
if (responseStatus && responseStatus === 404) {
console.error("could not find resource");
}
},
}),
queryCache: new QueryCache({
onError: (error) => {
console.log({ error });
const responseStatus = (error as AxiosError)?.response?.status;
if (responseStatus && responseStatus === 404) {
console.error('could not find resource');
}
},
}),
});

declare global {
interface Window {
gtag?: (
type: "event" | "config" | "get" | "set" | "consent",
action: "login" | "page_view",
options?: any
) => void;
}
interface Window {
gtag?: (
type: 'event' | 'config' | 'get' | 'set' | 'consent',
action: 'login' | 'page_view',
options?: any
) => void;
}
}

function App() {
const notistackRef = useRef<SnackbarProvider>(null);
useGetToken();
useGoogleAnalytics();
const notistackRef = useRef<SnackbarProvider>(null);
useGetToken();
useGoogleAnalytics();

const location = useLocation();
useEffect(() => {
if (window.gtag) {
window.gtag("event", "page_view", {
page_path: `${location.pathname}${location.search}`,
});
}
}, [location]);
const location = useLocation();
useEffect(() => {
if (window.gtag) {
window.gtag('event', 'page_view', {
page_path: `${location.pathname}${location.search}`,
});
}
}, [location]);

const handleCloseSnackbar =
(key: SnackbarKey) => (_event: React.MouseEvent) => {
if (notistackRef?.current?.closeSnackbar)
notistackRef.current?.closeSnackbar(key);
const handleCloseSnackbar = (key: SnackbarKey) => (_event: React.MouseEvent) => {
if (notistackRef?.current?.closeSnackbar) notistackRef.current?.closeSnackbar(key);
};

return (
<QueryClientProvider client={queryClient}>
<SnackbarProvider
ref={notistackRef}
autoHideDuration={8000}
action={(key) => (
<IconButton onClick={handleCloseSnackbar(key)}>
<Close sx={{ color: "white" }} />
</IconButton>
)}
>
<Banner />
<Navbar />
<BaseNavigation />
</SnackbarProvider>
</QueryClientProvider>
);
return (
<QueryClientProvider client={queryClient}>
<SnackbarProvider
ref={notistackRef}
autoHideDuration={8000}
action={(key) => (
<IconButton onClick={handleCloseSnackbar(key)}>
<Close sx={{ color: 'white' }} />
</IconButton>
)}
>
<Banner />
<Navbar />
<BaseNavigation />
</SnackbarProvider>
</QueryClientProvider>
);
}

export default App;
Loading