diff --git a/moped-editor/src/views/projects/projectView/ProjectSummary/ProjectSummary.js b/moped-editor/src/views/projects/projectView/ProjectSummary/ProjectSummary.js index d2958205fe..9e3c4604df 100644 --- a/moped-editor/src/views/projects/projectView/ProjectSummary/ProjectSummary.js +++ b/moped-editor/src/views/projects/projectView/ProjectSummary/ProjectSummary.js @@ -128,9 +128,10 @@ const ProjectSummary = ({ loading, error, data, refetch, listViewQuery }) => { const [snackbarState, setSnackbarState] = useState(false); - const childProjectGeography = data?.childProjects.map( - (project) => project.project_geography[0] - ); + /* Not all child components have components and geography data */ + const childProjectGeography = data?.childProjects + .filter((project) => project.project_geography.length > 0) + .map((project) => project.project_geography[0]); /** * Updates the state of snackbar state * @param {String|JSX.Element} message - The message to be displayed diff --git a/moped-editor/src/views/projects/projectView/ProjectSummary/ProjectSummaryCouncilDistricts.js b/moped-editor/src/views/projects/projectView/ProjectSummary/ProjectSummaryCouncilDistricts.js index 14694ca2e0..311a183c33 100644 --- a/moped-editor/src/views/projects/projectView/ProjectSummary/ProjectSummaryCouncilDistricts.js +++ b/moped-editor/src/views/projects/projectView/ProjectSummary/ProjectSummaryCouncilDistricts.js @@ -1,13 +1,16 @@ import React from "react"; import { Box, Grid, Typography } from "@mui/material"; -// reduce the array of geography objects into an array of city council districts +// reduce the array of project_geography objects into an array of city council districts const reduceDistricts = (data) => { const initialValue = []; - const districts = data.reduce( - (acc, component) => [...acc, component["council_districts"]], - initialValue - ); + const districts = data.reduce((acc, geography) => { + /* Not all components have geography data */ + const geographyCouncilDistricts = geography + ? geography.council_districts + : []; + return [...acc, geographyCouncilDistricts]; + }, initialValue); // flatten the array of arrays and remove empty districts const districtsArray = districts.flat().filter((d) => d);