Skip to content

Commit

Permalink
CMS-225: More encompassing null checks for accessStatus (#1339)
Browse files Browse the repository at this point in the history
  • Loading branch information
molund authored Jun 7, 2024
1 parent dedb05f commit a53846b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/cms/src/api/public-advisory/controllers/public-advisory.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,14 @@ module.exports = createCoreController(
});
const results = {};
for (const advisory of entries) {
for (const pa of advisory.protectedAreas) {
if (!results[pa.id]) {
results[pa.id] = [{ accessStatusId: advisory.accessStatus.id }]
} else {
if (!results[pa.id].find(x => x.accessStatusId === advisory.accessStatus?.id)) {
results[pa.id].push({ accessStatusId: advisory.accessStatus.id })
if (advisory.accessStatus) {
for (const pa of advisory.protectedAreas) {
if (!results[pa.id]) {
results[pa.id] = [{ accessStatusId: advisory.accessStatus.id }]
} else {
if (!results[pa.id].find(x => x.accessStatusId === advisory.accessStatus.id)) {
results[pa.id].push({ accessStatusId: advisory.accessStatus.id })
}
}
}
}
Expand Down

0 comments on commit a53846b

Please sign in to comment.