Skip to content

Commit

Permalink
fix: catch empty projections
Browse files Browse the repository at this point in the history
  • Loading branch information
friedjoff committed Apr 9, 2020
1 parent 9de577f commit 46af026
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
18 changes: 11 additions & 7 deletions src/components/ProjectionResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,25 +96,29 @@ function ProjectionResult() {
const TAZToday = getAZ(location.altitudinalZone);
const TAZModerate = getAZ(location.targetAltitudinalZoneModerate);
const TAZExtreme = getAZ(location.targetAltitudinalZoneExtreme);
const moderate = projectionResult.moderate.projections.slice(-1)[0] || {};
const extreme = projectionResult.extreme.projections.slice(-1)[0] || {};
const moderateLoc = projectionResult.moderate.projections
? projectionResult.moderate.projections.slice(-1)[0] || {}
: {};
const extremeLoc = projectionResult.extreme.projections
? projectionResult.extreme.projections.slice(-1)[0] || {}
: {};
if (TAZModerate === TAZExtreme) {
if (TAZToday === TAZModerate) {
panes.push(getPane('todayModerateExtreme', location, i18n.language, t));
} else {
panes.push(getPane('today', location, i18n.language, t));
panes.push(getPane('moderateExtreme', moderate, i18n.language, t));
panes.push(getPane('moderateExtreme', moderateLoc, i18n.language, t));
}
} else if (TAZToday === TAZModerate) {
panes.push(getPane('todayModerate', location, i18n.language, t));
panes.push(getPane('extreme', extreme, i18n.language, t));
panes.push(getPane('extreme', extremeLoc, i18n.language, t));
} else if (TAZToday === TAZExtreme) {
panes.push(getPane('moderate', moderate, i18n.language, t));
panes.push(getPane('todayExtreme', location, i18n.language, t));
panes.push(getPane('moderate', moderateLoc, i18n.language, t));
} else {
panes.push(getPane('today', location, i18n.language, t));
panes.push(getPane('moderate', moderate, i18n.language, t));
panes.push(getPane('extreme', extreme, i18n.language, t));
panes.push(getPane('moderate', moderateLoc, i18n.language, t));
panes.push(getPane('extreme', extremeLoc, i18n.language, t));
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/components/Recommendation.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ function Recommendation() {
projections = projectionResult.form.projections;
} else {
const { moderate, extreme } = projectionResult;
projections = [...moderate.projections, ...extreme.projections];
projections = [
...(moderate.projections || []),
...(extreme.projections || []),
];
}

try {
Expand Down

0 comments on commit 46af026

Please sign in to comment.