Skip to content

Commit

Permalink
fix(storefront): BCTHEME-514 Translation Gap: Gift Certificate -> Cod…
Browse files Browse the repository at this point in the history
…e required message
  • Loading branch information
yurytut1993 committed May 19, 2021
1 parent f92352c commit ad7c7e2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
8 changes: 5 additions & 3 deletions assets/js/theme/cart.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import PageManager from './page-manager';
import { bind, debounce } from 'lodash';
import giftCertCheck from './common/gift-certificate-validator';
import checkIsGiftCertValid from './common/gift-certificate-validator';
import { createTranslationDictionary } from './common/utils/translations-utils';
import utils from '@bigcommerce/stencil-utils';
import ShippingEstimator from './cart/shipping-estimator';
import { defaultModal } from './global/modal';
Expand Down Expand Up @@ -363,9 +364,10 @@ export default class Cart extends PageManager {

event.preventDefault();

if (!giftCertCheck(code)) {
if (!checkIsGiftCertValid(code)) {
const validationDictionary = createTranslationDictionary(this.context);
return swal.fire({
text: $certInput.data('error'),
text: validationDictionary.invalid_gift_certificate,
icon: 'error',
});
}
Expand Down
2 changes: 1 addition & 1 deletion assets/js/theme/common/gift-certificate-validator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default function (cert) {
if (typeof cert !== 'string') {
if (typeof cert !== 'string' || cert.length === 0) {
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions assets/js/theme/gift-certificate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PageManager from './page-manager';
import nod from './common/nod';
import giftCertChecker from './common/gift-certificate-validator';
import checkIsGiftCertValid from './common/gift-certificate-validator';
import formModel from './common/models/forms';
import { createTranslationDictionary } from './common/utils/translations-utils';
import { announceInputErrorMessage } from './common/utils/form-utils';
Expand Down Expand Up @@ -204,9 +204,9 @@ export default class GiftCertificate extends PageManager {
balanceValidator.add({
selector: $balanceForm.find('input[name="giftcertificatecode"]'),
validate(cb, val) {
cb(giftCertChecker(val));
cb(checkIsGiftCertValid(val));
},
errorMessage: 'You must enter a certificate code.',
errorMessage: this.validationDictionary.invalid_gift_certificate,
});

return balanceValidator;
Expand Down
9 changes: 6 additions & 3 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,8 @@
"price_max_evaluation": "Min. price must be less than max. price.",
"price_min_not_entered": "Min. price is required.",
"price_max_not_entered": "Max. price is required.",
"price_invalid_value": "Input must be greater than 0."
"price_invalid_value": "Input must be greater than 0.",
"invalid_gift_certificate": "Please enter your valid certificate code."
},
"validation_fallback_messages": {
"valid_email": "You must enter a valid email.",
Expand All @@ -937,7 +938,8 @@
"price_max_evaluation": "Min. price must be less than max. price.",
"price_min_not_entered": "Min. price is required.",
"price_max_not_entered": "Max. price is required.",
"price_invalid_value": "Input must be greater than 0."
"price_invalid_value": "Input must be greater than 0.",
"invalid_gift_certificate": "Please enter your valid certificate code."
},
"validation_default_messages": {
"valid_email": "You must enter a valid email.",
Expand All @@ -951,6 +953,7 @@
"price_max_evaluation": "Min. price must be less than max. price.",
"price_min_not_entered": "Min. price is required.",
"price_max_not_entered": "Max. price is required.",
"price_invalid_value": "Input must be greater than 0."
"price_invalid_value": "Input must be greater than 0.",
"invalid_gift_certificate": "Please enter your valid certificate code."
}
}

0 comments on commit ad7c7e2

Please sign in to comment.