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

Fix an error message is in English in Spanish account when validate 2nd contact #22100

Merged
merged 3 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document object parameters with separate lines e.g. @param {Object} parameters followed by @param {String} parameters.field.

It is missing the field errorFields. Pretty much similar to the JSDoc on getLatestErrorField.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just updated the above feedbacks. Please help me review this PR again. Thanks

* @param {Object} onyxData.errorFields
* @param {String} fieldName
* @returns {Object}
*/
function getFirstErrorField(onyxData, fieldName) {
Beamanator marked this conversation as resolved.
Show resolved Hide resolved
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, getFirstErrorField, addErrorMessage};
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function BaseValidateCodeForm(props) {
</OfflineWithFeedback>
<OfflineWithFeedback
pendingAction={lodashGet(loginData, 'pendingFields.validateLogin', null)}
errors={ErrorUtils.getLatestErrorField(loginData, 'validateLogin')}
errors={ErrorUtils.getFirstErrorField(loginData, 'validateLogin')}
errorRowStyles={[styles.mt2]}
onClose={() => User.clearContactMethodErrors(props.contactMethod, 'validateLogin')}
>
Expand Down