This commit is contained in:
Sneha 2023-11-13 20:11:00 +05:30
parent 33d2db26d7
commit ae505070c2
2 changed files with 10 additions and 7 deletions

View file

@ -16,7 +16,7 @@ export const addableVapsPromoPartNumbers = [
promoPartNumberStrings.WIPER_DISCOUNT_PART_NUMBER, promoPartNumberStrings.WIPER_DISCOUNT_PART_NUMBER,
]; ];
const promoErrorCodes = { export const promoErrorCodes = {
UNKNOWN: "Unknown", UNKNOWN: "Unknown",
PROMO_NOT_YET_IN_USE: "PromoNotYetInUse", PROMO_NOT_YET_IN_USE: "PromoNotYetInUse",
PROMO_USAGE_COUNT_EXCEEDED: "PromoUsageCountExceeded", PROMO_USAGE_COUNT_EXCEEDED: "PromoUsageCountExceeded",

View file

@ -9,6 +9,7 @@
<modal <modal
:ref="modalName" :ref="modalName"
:headerText="modalHeaderText" :headerText="modalHeaderText"
:onModalClosedCallback="onModalClosed"
:footerButtonText="modalFooterText" :footerButtonText="modalFooterText"
@footer-button-event="addPromoCode"> @footer-button-event="addPromoCode">
<promoQuestion <promoQuestion
@ -50,7 +51,10 @@ import promoQuestion from "@/layouts/payment-method/promo-modal-question/promo-q
import modal from "@/digital-components/modal/modal"; import modal from "@/digital-components/modal/modal";
import alert from "@/ux-components/alert/alert"; import alert from "@/ux-components/alert/alert";
import { storeActions } from "@/constants/store-actions.js"; import { storeActions } from "@/constants/store-actions.js";
import { getVapsThatNeedToBeAddedToSatisfyPromos } from "@/helpers/promotions-helper"; import {
getVapsThatNeedToBeAddedToSatisfyPromos,
promoErrorCodes,
} from "@/helpers/promotions-helper";
import { deepClone } from "@/helpers/object-helper"; import { deepClone } from "@/helpers/object-helper";
import baseMixin from "@/mixins/base-mixin.js"; import baseMixin from "@/mixins/base-mixin.js";
import { cartItemCategories } from "@/constants/cart-item-categories"; import { cartItemCategories } from "@/constants/cart-item-categories";
@ -125,6 +129,9 @@ export default {
closeModal() { closeModal() {
this.modal.closeModal(); this.modal.closeModal();
}, },
onModalClosed() {
this.$emit("update:modelValue", this.lineItems);
},
focusOnPromoInput() { focusOnPromoInput() {
const input = document.getElementById(this.promoTextInputId); const input = document.getElementById(this.promoTextInputId);
input?.focus(); input?.focus();
@ -160,12 +167,9 @@ export default {
}; };
}, },
removeItem(promo) { removeItem(promo) {
//let lineItems = this.modelValue;
this.lineItems[cartItemCategories.PROMOS] = this.lineItems[ this.lineItems[cartItemCategories.PROMOS] = this.lineItems[
cartItemCategories.PROMOS cartItemCategories.PROMOS
].filter((lineItemsToKeep) => lineItemsToKeep.promoCode != promo); ].filter((lineItemsToKeep) => lineItemsToKeep.promoCode != promo);
this.$emit("update:modelValue", this.lineItems);
}, },
async addPromoCode() { async addPromoCode() {
if (this.promoCode) { if (this.promoCode) {
@ -212,10 +216,9 @@ export default {
this.lineItems?.promos.push(...promoCodeData.promoCode); this.lineItems?.promos.push(...promoCodeData.promoCode);
this.lineItems.vaps?.push(...getVaps); this.lineItems.vaps?.push(...getVaps);
this.closeModal(); this.closeModal();
this.$emit("update:modelValue", this.lineItems);
this.promoCode = ""; this.promoCode = "";
} else { } else {
if (promoCodeData.errorCode == "PromoStackingNotAllowed") { if (promoCodeData.errorCode == promoErrorCodes.PROMO_STACKING_NOT_ALLOWED) {
this.displayInvalidPromoOnOrderAlert = true; this.displayInvalidPromoOnOrderAlert = true;
this.focusOnPromoInput(); this.focusOnPromoInput();
this.resetModalButtonStyle(); this.resetModalButtonStyle();