From 231d64ad45455bcdcec0d399ce1e72fa84d392f9 Mon Sep 17 00:00:00 2001 From: tinazarb Date: Wed, 15 Feb 2023 20:01:41 -0500 Subject: [PATCH] updated navigation text and routes from Reports to Dashboard --- client/Routes.jsx | 4 +- client/components/Header.jsx | 10 ++--- client/components/main/Dashboard.jsx | 67 ++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 7 deletions(-) create mode 100644 client/components/main/Dashboard.jsx diff --git a/client/Routes.jsx b/client/Routes.jsx index 5bb8d9f3d..95f1b1e1c 100644 --- a/client/Routes.jsx +++ b/client/Routes.jsx @@ -10,7 +10,7 @@ import theme, { darkTheme } from '@theme/theme'; import Paper from '@material-ui/core/Paper'; import Box from '@material-ui/core/Box'; import Desktop from '@components/main/Desktop'; -import Reports from '@components/main/Reports'; +import Dashboard from '@components/main/Dashboard'; import Privacy from '@components/main/Privacy'; import Faqs from '@components/main/Faqs'; import About from '@components/main/About'; @@ -36,7 +36,7 @@ export default function Routes() { - + diff --git a/client/components/Header.jsx b/client/components/Header.jsx index 721efe840..997a325c5 100644 --- a/client/components/Header.jsx +++ b/client/components/Header.jsx @@ -75,14 +75,14 @@ const Header = () => { { }} classes={{ paper: classes.menuPaper }} > - + Overview - + Compare Two Neighborhoods diff --git a/client/components/main/Dashboard.jsx b/client/components/main/Dashboard.jsx new file mode 100644 index 000000000..ebe148de6 --- /dev/null +++ b/client/components/main/Dashboard.jsx @@ -0,0 +1,67 @@ +import React from 'react'; +import { useLocation } from 'react-router-dom'; +import { makeStyles } from '@material-ui/core/styles'; +import { Backdrop, CircularProgress } from '@material-ui/core'; + +const useStyles = makeStyles(theme => ({ + root: { + height: `calc(100vh - ${theme.header.height} - ${theme.footer.height})`, + width: '100vw', + }, + backdrop: { + position: 'absolute', + top: theme.header.height, + bottom: theme.footer.height, + height: `calc(100vh - ${theme.header.height} - ${theme.footer.height})`, + }, +})); + +const DASHBOARD_PATH = '/dashboard/'; + +const Dashboard = () => { + const [isLoading, setIsLoading] = React.useState(true); + const classes = useStyles(); + + const url = process.env.REPORT_URL; + const location = useLocation(); + const dashboardPath = location.pathname.slice(DASHBOARD_PATH.length - 1); + const dashboardRef = React.useRef(dashboardPath); + + React.useEffect(() => { + if (dashboardPath !== dashboardRef.current) { + setIsLoading(true); + } + + if (isLoading) { + const timer = setTimeout(() => setIsLoading(false), 2000); + return () => clearTimeout(timer); + } + dashboardRef.current = dashboardPath; + + return () => { + // componentWillUnmount code goes here... + }; + }, [dashboardPath, isLoading]); + + return ( +
+ + + +