From e2c86d0516b094492d72d575957316db242bc2be Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Wed, 15 Nov 2023 11:13:51 -0500 Subject: [PATCH] CSR-1452 | Formatting --- src/helpers/promotions-helper.js | 24 ++++++++++------- src/layouts/payment-method/payment-method.vue | 26 ++++++++++++++----- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/helpers/promotions-helper.js b/src/helpers/promotions-helper.js index 98ae47c95..b8b8f2b4e 100644 --- a/src/helpers/promotions-helper.js +++ b/src/helpers/promotions-helper.js @@ -173,7 +173,10 @@ export function buildToastMessagesFromRevalidateOrValidatePromoResponse( alerts.push(createPromoSuccessAlert(newlyActivatedPromoCode)); }); - const newlyInactivatedPromos = getNewlyInactivatedPromos(oldInactivePromos, promoResponse.errors); + const newlyInactivatedPromos = getNewlyInactivatedPromos( + oldInactivePromos, + promoResponse.errors + ); newlyInactivatedPromos.forEach((newlyInactivatedPromo) => { alerts.push(createPromoErrorAlert(newlyInactivatedPromo)); }); @@ -264,9 +267,8 @@ export function shouldStripPromoQueryString(fmgPageQueryValue) { } export function getNewlyInactivatedPromos(oldInactivePromos, newInactivePromos) { - const inactivePromoCodesFromResponse = getPromoCodesFromPromoObjectsWithoutDuplicates( - newInactivePromos - ); + const inactivePromoCodesFromResponse = + getPromoCodesFromPromoObjectsWithoutDuplicates(newInactivePromos); return inactivePromoCodesFromResponse.filter( (errorPromoCode) => !oldInactivePromos.includes(errorPromoCode) ); @@ -275,7 +277,9 @@ export function getNewlyInactivatedPromos(oldInactivePromos, newInactivePromos) export function createPromoSuccessAlert(promoCode) { return { messageHeadline: "Promo applied!", - messageCopy: `Promo "${getPromoCodeWithoutBundleIdentifier(promoCode.toUpperCase())}" was successfully applied to your cart.`, + messageCopy: `Promo "${getPromoCodeWithoutBundleIdentifier( + promoCode.toUpperCase() + )}" was successfully applied to your cart.`, type: "alert-success", isDismissible: true, shouldAutoFade: true, @@ -290,9 +294,13 @@ export function createPromoErrorAlert(promoCode, errorCode = null, additionalInf isDismissible: true, }; if (stackingPromoErrorCodes.includes(errorCode)) { - alert.messageCopy = `Sorry, promo code "${getPromoCodeWithoutBundleIdentifier(promoCode.toUpperCase())}" cannot be combined with "${additionalInfo[0].toUpperCase()}"`; + alert.messageCopy = `Sorry, promo code "${getPromoCodeWithoutBundleIdentifier( + promoCode.toUpperCase() + )}" cannot be combined with "${additionalInfo[0].toUpperCase()}"`; } else { - alert.messageCopy = `Sorry, promo code "${getPromoCodeWithoutBundleIdentifier(promoCode.toUpperCase())}" is not valid`; + alert.messageCopy = `Sorry, promo code "${getPromoCodeWithoutBundleIdentifier( + promoCode.toUpperCase() + )}" is not valid`; } return alert; } @@ -318,5 +326,3 @@ function getPromoCodesFromPromoObjectsWithoutDuplicates(promos) { return promoCodes; } - - diff --git a/src/layouts/payment-method/payment-method.vue b/src/layouts/payment-method/payment-method.vue index 0212b3f01..7cc4f4372 100644 --- a/src/layouts/payment-method/payment-method.vue +++ b/src/layouts/payment-method/payment-method.vue @@ -225,7 +225,10 @@ export default { vm.setCmsContent(resultMap.cmsContent); vm.availableVaps = taxedVaps; vm.lineItems = lineItems; - vm.inactivePromos = removeCurrentlyActivePromoCodesFromInactivePromos(vm.lineItems.promos, vm.inactivePromos); + vm.inactivePromos = removeCurrentlyActivePromoCodesFromInactivePromos( + vm.lineItems.promos, + vm.inactivePromos + ); vm.updateFooterButtonText(vm.customCtaCopy); if (revalidatePromoResponse) { @@ -343,13 +346,18 @@ export default { ); // Handle error alerts here, success alerts are handled in the watcher if (revalidatePromoResponse.errors.length) { - getNewlyInactivatedPromos(this.inactivePromos, revalidatePromoResponse.errors).forEach(promoCode => { + getNewlyInactivatedPromos( + this.inactivePromos, + revalidatePromoResponse.errors + ).forEach((promoCode) => { const errorAlert = createPromoErrorAlert(promoCode); this.$refs.funnelHeader.pushGlobalAlert(errorAlert, errorAlert.shouldAutoFade); }); } this.lineItems.promos = revalidatePromoResponse.promoLineItems; - this.inactivePromos = revalidatePromoResponse.errors.map((x) => getPromoCodeWithoutBundleIdentifier(x.promoCode)); + this.inactivePromos = revalidatePromoResponse.errors.map((x) => + getPromoCodeWithoutBundleIdentifier(x.promoCode) + ); this.$refs.loadingModal.hideModal(); }, backButtonAction() { @@ -484,14 +492,18 @@ export default { return; } if (oldValue.promos.length < newValue.promos.length) { - const oldPromoCodes = oldValue.promos.map(promoObject => promoObject.promoCode); + const oldPromoCodes = oldValue.promos.map( + (promoObject) => promoObject.promoCode + ); const newlyActivatedPromoCodes = newValue.promos.filter( (newPromo) => !oldPromoCodes.includes(newPromo.promoCode) ); - const alert = createPromoSuccessAlert(newlyActivatedPromoCodes[0].promoCode) + const alert = createPromoSuccessAlert(newlyActivatedPromoCodes[0].promoCode); this.$refs.funnelHeader.pushGlobalAlert(alert, alert.shouldAutoFade); - } - else if (oldValue.promos.length == newValue.promos.length && oldValue.vaps.length != newValue.vaps.length) { + } else if ( + oldValue.promos.length == newValue.promos.length && + oldValue.vaps.length != newValue.vaps.length + ) { this.revalidatePromos(); } },