-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(section-form): prevent crash when displayOptions are not present (#…
…375) * fix(section-form): prevent crash when displayOptions are not present * refactor: cleanup
- Loading branch information
Showing
2 changed files
with
29 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const defaultDisplayOptions = { | ||
beforeSectionText: '', | ||
pivotMode: 'n/a', | ||
afterSectionText: '', | ||
pivotCategory: null, | ||
} | ||
export const getDisplayOptions = (section) => { | ||
if (!section) { | ||
return defaultDisplayOptions | ||
} | ||
|
||
try { | ||
const { displayOptions: displayOptionString } = section | ||
|
||
return JSON.parse(displayOptionString) | ||
} catch (e) { | ||
console.error( | ||
`Failed to parse displayOptions for section ${section?.displayName}(${section?.id})`, | ||
e | ||
) | ||
return defaultDisplayOptions | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ef3cce1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://dhis2-data-entry.netlify.app as production
🚀 Deployed on https://663a1468de8071131855f541--dhis2-data-entry.netlify.app