diff --git a/client/src/actions/search.js b/client/src/actions/search.js index 1a63138..0df46fe 100644 --- a/client/src/actions/search.js +++ b/client/src/actions/search.js @@ -196,13 +196,12 @@ export function handleAllTotalsQuery(year) { dispatch( updateAllTotals({ timelineData: res.speculationByYear - .map(({ year: recYear, count }) => ({ - x: +recYear, - y: +count, + .map((rec) => ({ + ...rec, + x: +rec.year, + y: +rec.count, })) - .sort((a, b) => a.recYear - b.recYear), - totalSpeculators: +yearRecord.speculator_count, - totalParcels: +yearRecord.count, + .sort((a, b) => a.year - b.year), topSpeculators: res.topSpeculators, }) ) diff --git a/client/src/components/Search/AllParcels.jsx b/client/src/components/Search/AllParcels.jsx index d53ad8a..04fca4c 100644 --- a/client/src/components/Search/AllParcels.jsx +++ b/client/src/components/Search/AllParcels.jsx @@ -20,12 +20,21 @@ import infoIcon from "../../assets/img/info-icon.png" function AllParcels(props) { const year = props.queryParams?.year || DEFAULT_YEAR - const { timelineData, totalSpeculators, totalParcels, topSpeculators } = - useSelector((state) => state.searchState.allTotals) + const { timelineData, topSpeculators } = useSelector( + (state) => state.searchState.allTotals + ) const { drawerIsOpen } = useSelector( (state) => state.searchState.detailedSearch ) + const yearRecord = timelineData.find( + ({ year: recYear }) => +year === +recYear + ) + if (!yearRecord) { + return + } + const { speculator_count: totalSpeculators, count: totalParcels } = yearRecord + return ( totalSpeculators && (