Skip to content

Commit

Permalink
Add the date of the last published report to the dashboard view
Browse files Browse the repository at this point in the history
  • Loading branch information
elias-garcia committed Apr 3, 2020
1 parent 48720a0 commit a8757cf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const mapStateToProps = (state: State): DashboardStateProps => ({
isInitialDataLoading:
state.dashboard.latestReport.step === "loading" ||
state.dashboard.accumulatedValues.step === "loading",
lastReportUpdate:
state.dashboard.latestReport.step !== "successful"
? undefined
: state.dashboard.latestReport.result.timestamp,
});

const mapDispatchToProps = (
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/routes/dashboard/dashboard.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const useStyles = makeStyles((theme: Theme) => ({
height: "100%",
width: "100%",
},
lastReportUpdate: {
paddingBottom: theme.spacing(6),
},
widget: {
paddingBottom: theme.spacing(6),
"&:last-of-type": {
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/components/routes/dashboard/dashboard.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import useStyles from "./dashboard.styles";
import AccumulatedValuesWidgetContainer from "./components/accumulated-values-widget/accumulated-values-widget.container";
import ChoroplethWidgetContainer from "./components/choropleth-widget/choropleth-widget.container";
import LoadingSpinner from "../../shared/loading-spinner/loading-spinner.view";
import { Typography } from "@material-ui/core";

export interface DashboardStateProps {
readonly isInitialDataLoading: boolean;
readonly lastReportUpdate: string | undefined;
}

export interface DashboardHandlerProps {
Expand All @@ -18,6 +20,7 @@ type DashboardProps = DashboardStateProps & DashboardHandlerProps;

const Dashboard: React.FC<DashboardProps> = ({
isInitialDataLoading,
lastReportUpdate,
onLoadData,
onAbortDataLoading,
}: DashboardProps) => {
Expand All @@ -29,12 +32,18 @@ const Dashboard: React.FC<DashboardProps> = ({
return () => onAbortDataLoading();
}, [onLoadData, onAbortDataLoading]);

if (isInitialDataLoading) {
if (isInitialDataLoading || !lastReportUpdate) {
return <LoadingSpinner />;
}

return (
<div className={classes.pageLoadedWrapper}>
<div className={classes.lastReportUpdate}>
<Typography variant="h5">
Date of the last published report:&nbsp;
{new Date(lastReportUpdate).toLocaleDateString()}
</Typography>
</div>
<div className={classes.widget}>
<AccumulatedValuesWidgetContainer />
</div>
Expand Down

0 comments on commit a8757cf

Please sign in to comment.