From af512667f02bddcefe4327a857e0202bc549cf57 Mon Sep 17 00:00:00 2001 From: Sneha Date: Thu, 23 Nov 2023 12:01:27 +0530 Subject: [PATCH 1/3] error message --- .../promo-modal-question.vue | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue b/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue index cde033066..3f7e4368a 100644 --- a/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue +++ b/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue @@ -26,7 +26,14 @@ class="my-4 alert" cmsWidgetName="AlertInvalidPromoWidget" alertClass="alert-danger" - v-bind:isDismissible="true" /> + v-bind:isDismissible="false" /> + + v-bind:isDismissible="false" />
Promo code "{{ promoCode }}" applied Date: Fri, 24 Nov 2023 11:35:44 +0530 Subject: [PATCH 2/3] CSR-1827 --- .../promo-modal-question.spec.js | 4 +- .../promo-modal-question.vue | 85 ++++++++++++++----- 2 files changed, 66 insertions(+), 23 deletions(-) diff --git a/src/layouts/payment-method/promo-modal-question/promo-modal-question.spec.js b/src/layouts/payment-method/promo-modal-question/promo-modal-question.spec.js index 94de72765..110ece01e 100644 --- a/src/layouts/payment-method/promo-modal-question/promo-modal-question.spec.js +++ b/src/layouts/payment-method/promo-modal-question/promo-modal-question.spec.js @@ -49,7 +49,9 @@ describe("promo-modal-question.vue", () => { // Assert expect(wrapper.vm.displayInvalidPromoAlert).toBe(false); - expect(wrapper.vm.displayInvalidOnOrderPromoAlert).toBe(false); + expect(wrapper.vm.displayStackingPromoAlert).toBe(false); + expect(wrapper.vm.displayInShopPromoAlert).toBe(false); + expect(wrapper.vm.displaySimilarPromoAlert).toBe(false); }); it("Should emit update:modelValue on Modal closed", async () => { // Arrange diff --git a/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue b/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue index 3f7e4368a..bf0359b37 100644 --- a/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue +++ b/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue @@ -22,7 +22,7 @@ +
@@ -78,9 +86,11 @@ export default { return { promoCode: "", promoTextInputId: "", + errorMessage: "", displayInvalidPromoAlert: false, displaySimilarPromoAlert: false, - displayInvalidOnOrderPromoAlert: false, + displayStackingPromoAlert: false, + displayInShopPromoAlert: false, lineItems: deepClone(this.modelValue), }; }, @@ -105,20 +115,14 @@ export default { modal() { return this.$refs[this.modalName]; }, - PromoOnOrderText() { - return this.getCmsContent("AlertInvalidPromoOnOrderWidget", "HeadlineText"); - }, - InvalidPromoOnOrderText() { - return this.PromoOnOrderText?.replaceAll( - "{custom:NEWPROMOCODE}", - this.promoCode.toUpperCase() - ).replaceAll("{custom:OLDPROMOCODE}", this.getPromoCode()?.toUpperCase()); + StackPromoText() { + return this.getCmsContent("AlertStackingPromoWidget", "HeadlineText"); }, PromoText() { return this.getCmsContent("AlertInvalidPromoWidget", "HeadlineText"); }, - InvalidPromoText() { - return this.PromoText?.replaceAll("{custom:PROMOCODE}", this.promoCode.toUpperCase()); + InShopPromoText() { + return this.getCmsContent("AlertInshopPromoWidget", "HeadlineText"); }, removeLinkText() { return this.getCmsContent("RemoveCartItemTextWidget", "Text"); @@ -126,8 +130,11 @@ export default { }, methods: { resetAlerts() { - this.displayInvalidOnOrderPromoAlert = false; + this.displayStackingPromoAlert = false; this.displayInvalidPromoAlert = false; + this.displaySimilarPromoAlert = false; + this.displayInShopPromoAlert = false; + this.errorMessage = ""; }, resetsOnPromoInput() { this.resetAlerts(); @@ -138,8 +145,16 @@ export default { ); return promosToDisplay; }, - getPromoCode() { - return this.lineItems.promos?.[0]?.promoCode; + getConflictingPromoCode(additionalInfo) { + var conflictingCodes = additionalInfo?.[0]; + if (additionalInfo?.length > 1) { + if (additionalInfo?.length > 2) conflictingCodes += ","; + for (let i = 1; i < additionalInfo?.length - 1; i++) { + conflictingCodes += ` "${additionalInfo[i]}",`; + } + conflictingCodes += ` and "${additionalInfo?.slice(-1)[0]}"`; + } + return conflictingCodes; }, onInputIdAssigned(inputId) { this.promoTextInputId = inputId; @@ -194,10 +209,35 @@ export default { switch (error) { case promoErrorCodes.PROMO_STACKING_NOT_ALLOWED: case promoErrorCodes.SIMILAR_PROMO_ALREADY_ON_ORDER: - if (additionalInfo[0] === this.promoCode.toUpperCase()) + if ( + additionalInfo.length === 1 && + additionalInfo[0] === this.promoCode.toUpperCase() + ) { return (this.displaySimilarPromoAlert = true); - return (this.displayInvalidOnOrderPromoAlert = true); + } else { + this.errorMessage = this.StackPromoText?.replaceAll( + "{custom:NEWPROMOCODE}", + this.promoCode.toUpperCase() + ).replaceAll( + "{custom:OLDPROMOCODE}", + this.getConflictingPromoCode(additionalInfo) + ); + return (this.displayStackingPromoAlert = true); + } + case promoErrorCodes.INVALID_PROMO_ON_ORDER: + if (additionalInfo.some((x) => x.toUpperCase() === "APPOINTMENT_TYPE")) { + this.errorMessage = this.InShopPromoText?.replaceAll( + "{custom:INSHOPPROMOCODE}", + this.promoCode.toUpperCase() + ); + return (this.displayInShopPromoAlert = true); + } + break; default: + this.errorMessage = this.PromoText?.replaceAll( + "{custom:PROMOCODE}", + this.promoCode.toUpperCase() + ); return (this.displayInvalidPromoAlert = true); } }, @@ -257,8 +297,9 @@ export default { watch: { promoCode() { this.displayInvalidPromoAlert = false; - this.displayInvalidOnOrderPromoAlert = false; + this.displayStackingPromoAlert = false; this.displaySimilarPromoAlert = false; + this.displayInShopPromoAlert = false; }, modelValue: { handler(newValue) { From 860eed41517930c3be9dc75e5f4fde6da9b24c98 Mon Sep 17 00:00:00 2001 From: Sneha Date: Fri, 24 Nov 2023 14:44:01 +0530 Subject: [PATCH 3/3] Update promo-modal-question.vue --- .../promo-modal-question.vue | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue b/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue index bf0359b37..8cc561b03 100644 --- a/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue +++ b/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue @@ -209,21 +209,17 @@ export default { switch (error) { case promoErrorCodes.PROMO_STACKING_NOT_ALLOWED: case promoErrorCodes.SIMILAR_PROMO_ALREADY_ON_ORDER: - if ( - additionalInfo.length === 1 && + return additionalInfo.length === 1 && additionalInfo[0] === this.promoCode.toUpperCase() - ) { - return (this.displaySimilarPromoAlert = true); - } else { - this.errorMessage = this.StackPromoText?.replaceAll( - "{custom:NEWPROMOCODE}", - this.promoCode.toUpperCase() - ).replaceAll( - "{custom:OLDPROMOCODE}", - this.getConflictingPromoCode(additionalInfo) - ); - return (this.displayStackingPromoAlert = true); - } + ? (this.displaySimilarPromoAlert = true) + : ((this.errorMessage = this.StackPromoText?.replace( + /\{custom:(NEW|OLD)PROMOCODE\}/g, + (match, group) => + group === "NEW" + ? this.promoCode.toUpperCase() + : this.getConflictingPromoCode(additionalInfo) + )), + (this.displayStackingPromoAlert = true)); case promoErrorCodes.INVALID_PROMO_ON_ORDER: if (additionalInfo.some((x) => x.toUpperCase() === "APPOINTMENT_TYPE")) { this.errorMessage = this.InShopPromoText?.replaceAll(