Skip to content

Commit

Permalink
Merge pull request #22100 from hoangzinh/df/21001
Browse files Browse the repository at this point in the history
Fix an error message is in English in Spanish account when validate 2nd contact
  • Loading branch information
Beamanator authored Jul 6, 2023
2 parents a2a521d + 910780c commit 197cf7d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 21 additions & 1 deletion src/libs/ErrorUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,26 @@ function getLatestErrorField(onyxData, fieldName) {
.value();
}

/**
* @param {Object} onyxData
* @param {Object} onyxData.errorFields
* @param {String} fieldName
* @returns {Object}
*/
function getEarliestErrorField(onyxData, fieldName) {
const errorsForField = lodashGet(onyxData, ['errorFields', fieldName], {});

if (_.isEmpty(errorsForField)) {
return {};
}
return _.chain(errorsForField)
.keys()
.sortBy()
.map((key) => ({[key]: errorsForField[key]}))
.first()
.value();
}

/**
* Method used to generate error message for given inputID
* @param {Object} errors - An object containing current errors in the form
Expand All @@ -112,4 +132,4 @@ function addErrorMessage(errors, inputID, message) {
}
}

export {getAuthenticateErrorMessage, getMicroSecondOnyxError, getLatestErrorMessage, getLatestErrorField, addErrorMessage};
export {getAuthenticateErrorMessage, getMicroSecondOnyxError, getLatestErrorMessage, getLatestErrorField, getEarliestErrorField, addErrorMessage};
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function BaseValidateCodeForm(props) {
</OfflineWithFeedback>
<OfflineWithFeedback
pendingAction={lodashGet(loginData, 'pendingFields.validateLogin', null)}
errors={ErrorUtils.getLatestErrorField(loginData, 'validateLogin')}
errors={ErrorUtils.getEarliestErrorField(loginData, 'validateLogin')}
errorRowStyles={[styles.mt2]}
onClose={() => User.clearContactMethodErrors(props.contactMethod, 'validateLogin')}
>
Expand Down

0 comments on commit 197cf7d

Please sign in to comment.