Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update getSimplifiedPolicyObject to handle different policy objects #6739

Merged
merged 4 commits into from
Dec 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/libs/actions/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function getSimplifiedEmployeeList(employeeList) {
* @param {String} fullPolicyOrPolicySummary.role
* @param {String} fullPolicyOrPolicySummary.type
* @param {String} fullPolicyOrPolicySummary.outputCurrency
* @param {String} [fullPolicyOrPolicySummary.avatarURL]
* @param {String} [fullPolicyOrPolicySummary.value.avatarURL]
* @param {Object} [fullPolicyOrPolicySummary.value.employeeList]
* @returns {Object}
Expand All @@ -61,7 +62,10 @@ function getSimplifiedPolicyObject(fullPolicyOrPolicySummary) {
type: fullPolicyOrPolicySummary.type,
owner: fullPolicyOrPolicySummary.owner,
outputCurrency: fullPolicyOrPolicySummary.outputCurrency,
avatarURL: fullPolicyOrPolicySummary.avatarURL || '',

// "GetFullPolicy" and "GetPolicySummaryList" returns different policy objects. If policy is retrieved by "GetFullPolicy",
// avatarUrl will be nested within the key "value"
avatarURL: fullPolicyOrPolicySummary.avatarURL || lodashGet(fullPolicyOrPolicySummary, 'value.avatarURL', ''),
employeeList: getSimplifiedEmployeeList(lodashGet(fullPolicyOrPolicySummary, 'value.employeeList')),
};
}
Expand Down