CSR-1452 | Formatting
This commit is contained in:
parent
8d9fbdf985
commit
e2c86d0516
2 changed files with 34 additions and 16 deletions
|
|
@ -173,7 +173,10 @@ export function buildToastMessagesFromRevalidateOrValidatePromoResponse(
|
||||||
alerts.push(createPromoSuccessAlert(newlyActivatedPromoCode));
|
alerts.push(createPromoSuccessAlert(newlyActivatedPromoCode));
|
||||||
});
|
});
|
||||||
|
|
||||||
const newlyInactivatedPromos = getNewlyInactivatedPromos(oldInactivePromos, promoResponse.errors);
|
const newlyInactivatedPromos = getNewlyInactivatedPromos(
|
||||||
|
oldInactivePromos,
|
||||||
|
promoResponse.errors
|
||||||
|
);
|
||||||
newlyInactivatedPromos.forEach((newlyInactivatedPromo) => {
|
newlyInactivatedPromos.forEach((newlyInactivatedPromo) => {
|
||||||
alerts.push(createPromoErrorAlert(newlyInactivatedPromo));
|
alerts.push(createPromoErrorAlert(newlyInactivatedPromo));
|
||||||
});
|
});
|
||||||
|
|
@ -264,9 +267,8 @@ export function shouldStripPromoQueryString(fmgPageQueryValue) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getNewlyInactivatedPromos(oldInactivePromos, newInactivePromos) {
|
export function getNewlyInactivatedPromos(oldInactivePromos, newInactivePromos) {
|
||||||
const inactivePromoCodesFromResponse = getPromoCodesFromPromoObjectsWithoutDuplicates(
|
const inactivePromoCodesFromResponse =
|
||||||
newInactivePromos
|
getPromoCodesFromPromoObjectsWithoutDuplicates(newInactivePromos);
|
||||||
);
|
|
||||||
return inactivePromoCodesFromResponse.filter(
|
return inactivePromoCodesFromResponse.filter(
|
||||||
(errorPromoCode) => !oldInactivePromos.includes(errorPromoCode)
|
(errorPromoCode) => !oldInactivePromos.includes(errorPromoCode)
|
||||||
);
|
);
|
||||||
|
|
@ -275,7 +277,9 @@ export function getNewlyInactivatedPromos(oldInactivePromos, newInactivePromos)
|
||||||
export function createPromoSuccessAlert(promoCode) {
|
export function createPromoSuccessAlert(promoCode) {
|
||||||
return {
|
return {
|
||||||
messageHeadline: "Promo applied!",
|
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",
|
type: "alert-success",
|
||||||
isDismissible: true,
|
isDismissible: true,
|
||||||
shouldAutoFade: true,
|
shouldAutoFade: true,
|
||||||
|
|
@ -290,9 +294,13 @@ export function createPromoErrorAlert(promoCode, errorCode = null, additionalInf
|
||||||
isDismissible: true,
|
isDismissible: true,
|
||||||
};
|
};
|
||||||
if (stackingPromoErrorCodes.includes(errorCode)) {
|
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 {
|
} 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;
|
return alert;
|
||||||
}
|
}
|
||||||
|
|
@ -318,5 +326,3 @@ function getPromoCodesFromPromoObjectsWithoutDuplicates(promos) {
|
||||||
|
|
||||||
return promoCodes;
|
return promoCodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,10 @@ export default {
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
vm.availableVaps = taxedVaps;
|
vm.availableVaps = taxedVaps;
|
||||||
vm.lineItems = lineItems;
|
vm.lineItems = lineItems;
|
||||||
vm.inactivePromos = removeCurrentlyActivePromoCodesFromInactivePromos(vm.lineItems.promos, vm.inactivePromos);
|
vm.inactivePromos = removeCurrentlyActivePromoCodesFromInactivePromos(
|
||||||
|
vm.lineItems.promos,
|
||||||
|
vm.inactivePromos
|
||||||
|
);
|
||||||
vm.updateFooterButtonText(vm.customCtaCopy);
|
vm.updateFooterButtonText(vm.customCtaCopy);
|
||||||
|
|
||||||
if (revalidatePromoResponse) {
|
if (revalidatePromoResponse) {
|
||||||
|
|
@ -343,13 +346,18 @@ export default {
|
||||||
);
|
);
|
||||||
// Handle error alerts here, success alerts are handled in the watcher
|
// Handle error alerts here, success alerts are handled in the watcher
|
||||||
if (revalidatePromoResponse.errors.length) {
|
if (revalidatePromoResponse.errors.length) {
|
||||||
getNewlyInactivatedPromos(this.inactivePromos, revalidatePromoResponse.errors).forEach(promoCode => {
|
getNewlyInactivatedPromos(
|
||||||
|
this.inactivePromos,
|
||||||
|
revalidatePromoResponse.errors
|
||||||
|
).forEach((promoCode) => {
|
||||||
const errorAlert = createPromoErrorAlert(promoCode);
|
const errorAlert = createPromoErrorAlert(promoCode);
|
||||||
this.$refs.funnelHeader.pushGlobalAlert(errorAlert, errorAlert.shouldAutoFade);
|
this.$refs.funnelHeader.pushGlobalAlert(errorAlert, errorAlert.shouldAutoFade);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.lineItems.promos = revalidatePromoResponse.promoLineItems;
|
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();
|
this.$refs.loadingModal.hideModal();
|
||||||
},
|
},
|
||||||
backButtonAction() {
|
backButtonAction() {
|
||||||
|
|
@ -484,14 +492,18 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (oldValue.promos.length < newValue.promos.length) {
|
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(
|
const newlyActivatedPromoCodes = newValue.promos.filter(
|
||||||
(newPromo) => !oldPromoCodes.includes(newPromo.promoCode)
|
(newPromo) => !oldPromoCodes.includes(newPromo.promoCode)
|
||||||
);
|
);
|
||||||
const alert = createPromoSuccessAlert(newlyActivatedPromoCodes[0].promoCode)
|
const alert = createPromoSuccessAlert(newlyActivatedPromoCodes[0].promoCode);
|
||||||
this.$refs.funnelHeader.pushGlobalAlert(alert, alert.shouldAutoFade);
|
this.$refs.funnelHeader.pushGlobalAlert(alert, alert.shouldAutoFade);
|
||||||
}
|
} else if (
|
||||||
else if (oldValue.promos.length == newValue.promos.length && oldValue.vaps.length != newValue.vaps.length) {
|
oldValue.promos.length == newValue.promos.length &&
|
||||||
|
oldValue.vaps.length != newValue.vaps.length
|
||||||
|
) {
|
||||||
this.revalidatePromos();
|
this.revalidatePromos();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue