Skip to content

Commit

Permalink
fix: [DHIS2-14190] make sure option is non-null (#1885)
Browse files Browse the repository at this point in the history
  • Loading branch information
superskip authored Nov 8, 2023
1 parent a82ea07 commit aca8bfb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions d2-tracker/dhis2.angular.services.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,12 @@ var d2Services = angular.module('d2Services', ['ngResource'])
const keyString = String(key);

// is key a name?
const option = options.find(option => keyString === option.displayName);
const option = options.find(option => option && keyString === option.displayName);
if (option) {
return option.code;
}
// is key a code?
if (options.find(option => keyString === option.code)) {
if (options.find(option => option && keyString === option.code)) {
return key;
}
// not a part of the option set
Expand All @@ -471,12 +471,12 @@ var d2Services = angular.module('d2Services', ['ngResource'])
const keyString = String(key);

// is key a code?
const option = options.find(option => keyString === option.code);
const option = options.find(option => option && keyString === option.code);
if (option) {
return option.displayName;
}
// is key a name?
if (options.find(option => keyString === option.displayName)) {
if (options.find(option => option && keyString === option.displayName)) {
return key;
}
// not a part of the option set
Expand Down

0 comments on commit aca8bfb

Please sign in to comment.