Fixed grouping error in members CSV importer

no issue

- Import error grouping wasn't working correctly when error didn't have defined context property
- The copy will be refined in final design review
This commit is contained in:
Nazar Gargol 2020-06-30 00:22:52 +12:00
parent 51d506469d
commit 097ff9fba9
2 changed files with 9 additions and 3 deletions

View File

@ -225,7 +225,10 @@ const members = {
return decorateWithSubscriptions(member);
} catch (error) {
if (error.code && error.message.toLowerCase().indexOf('unique') !== -1) {
throw new errors.ValidationError({message: i18n.t('errors.api.members.memberAlreadyExists')});
throw new errors.ValidationError({
message: i18n.t('errors.api.members.memberAlreadyExists.message'),
context: i18n.t('errors.api.members.memberAlreadyExists.context')
});
}
// NOTE: failed to link Stripe customer/plan/subscription
@ -482,7 +485,7 @@ const members = {
}).then(() => {
// NOTE: grouping by context because messages can contain unique data like "customer_id"
const groupedErrors = _.groupBy(invalid.errors, 'context');
const uniqueErrors = _.uniq(invalid.errors, 'context');
const uniqueErrors = _.uniqBy(invalid.errors, 'context');
const outputErrors = uniqueErrors.map((error) => {
let errorGroup = groupedErrors[error.context];

View File

@ -368,7 +368,10 @@
},
"members": {
"memberNotFound": "Member not found.",
"memberAlreadyExists": "Email address is already member.",
"memberAlreadyExists": {
"message": "Email address is already member.",
"context": "Attempting to add member with existing email address."
},
"stripeNotConnected": {
"message": "Member not imported, Stripe account missing",
"context": "Attempting to import members with Stripe data when there is no Stripe account connected",