Skip to content

Commit

Permalink
Merge pull request #1459 from hackforla/1447-navigation-text-dashboard
Browse files Browse the repository at this point in the history
Updated navigation text and routes from 'Reports' to 'Dashboard'
  • Loading branch information
tinazarb authored Feb 16, 2023
2 parents d2ed129 + 231d64a commit 725e5db
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 7 deletions.
4 changes: 2 additions & 2 deletions client/Routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -36,7 +36,7 @@ export default function Routes() {
<ThemeProvider theme={theme}>
<Paper elevation={0}>
<Switch>
<Route path="/reports" component={Reports} />
<Route path="/dashboard" component={Dashboard} />
<Route path="/privacy" component={Privacy} />
<Route path="/faqs" component={Faqs} />
<Route path="/research" component={Research} />
Expand Down
10 changes: 5 additions & 5 deletions client/components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ const Header = () => {
<Button className={classes.button}>Map</Button>
</NavLink>
<Button
id="report-anchor"
id="dashboard-anchor"
onClick={handleClick}
className={classes.button}
>
Reports
Dashboard
</Button>
<Menu
id="report-menu"
id="dashboard-menu"
anchorEl={anchorEl}
keepMounted
open={Boolean(anchorEl)}
Expand All @@ -94,12 +94,12 @@ const Header = () => {
}}
classes={{ paper: classes.menuPaper }}
>
<Link to="/reports/overview-combined">
<Link to="/dashboard/overview-combined">
<MenuItem onClick={handleClose} className={classes.menuItem}>
Overview
</MenuItem>
</Link>
<Link to="/reports/nc-summary-comparison">
<Link to="/dashboard/nc-summary-comparison">
<MenuItem onClick={handleClose} className={classes.menuItem}>
Compare Two Neighborhoods
</MenuItem>
Expand Down
67 changes: 67 additions & 0 deletions client/components/main/Dashboard.jsx
Original file line number Diff line number Diff line change
@@ -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 (
<div className={classes.root}>
<Backdrop
className={classes.backdrop}
style={{ zIndex: 100 }}
open={isLoading}
invisible={!isLoading}
>
<CircularProgress />
</Backdrop>
<iframe
title="dashboardFrame"
src={url + dashboardPath}
frameBorder="0"
allowFullScreen
style={{ width: '100%', height: '100%' }}
/>
</div>
);
};

export default Dashboard;

0 comments on commit 725e5db

Please sign in to comment.