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 (#2064)
  • Loading branch information
yurytut1993 authored May 25, 2021
1 parent ea5da55 commit 9ca4c74
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Draft
- Translation Gap: Gift Certificate -> Code required message. [#2064](https://github.com/bigcommerce/cornerstone/pull/2064)
- Added translation for invalid quantity value error on Cart. [#2062](https://github.com/bigcommerce/cornerstone/pull/2062)
- Translation Gap: Delete from Cart confirmation popup. [#2065](https://github.com/bigcommerce/cornerstone/pull/2065)
- Fixed NaN error on increase/decrease product quantity by adding field validation. [#2052](https://github.com/bigcommerce/cornerstone/pull/2052)
Expand Down
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 @@ -364,9 +365,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
10 changes: 6 additions & 4 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
"gift_certificate": "Gift Certificate",
"code_label": "Gift Certificate ({code})",
"cert_code": "Enter your certificate code",
"empty_error": "Please enter your valid certificate code.",
"remove": "Remove"
},
"shipping_estimator": {
Expand Down Expand Up @@ -925,7 +924,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 @@ -939,7 +939,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 @@ -953,6 +954,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."
}
}
2 changes: 1 addition & 1 deletion templates/components/cart/gift-certificate-input.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="cart-form gift-certificate-code" style="display: none;">
<form class="form form--hiddenLabels cart-gift-certificate-form" method="post" action="{{urls.cart}}">
<label class="form-label" for="certcode">{{lang 'cart.gift_certificates.cert_code'}}</label>
<input class="form-input" data-error="{{lang 'cart.gift_certificates.empty_error'}}" id="certcode" type="text" name="certcode" value="" placeholder="{{lang 'cart.gift_certificates.add_cert_code'}}">
<input class="form-input" id="certcode" type="text" name="certcode" value="" placeholder="{{lang 'cart.gift_certificates.add_cert_code'}}">
<input class="button button--primary button--small" type="submit" value="{{lang 'cart.coupons.button'}}">
<input type="hidden" name="action" value="applycoupon">
</form>
Expand Down

0 comments on commit 9ca4c74

Please sign in to comment.