Update promo-modal-question.vue

This commit is contained in:
Sneha 2023-11-13 19:44:38 +05:30
parent 3873c23716
commit 33d2db26d7

View file

@ -24,7 +24,7 @@
cmsWidgetName="AlertInvalidPromoWidget" cmsWidgetName="AlertInvalidPromoWidget"
alertClass="alert-danger" alertClass="alert-danger"
v-bind:isDismissible="true" /> v-bind:isDismissible="true" />
<alert <alert
ref="alertInvalidPromoOnOrder" ref="alertInvalidPromoOnOrder"
v-if="displayInvalidOnOrderPromoAlert" v-if="displayInvalidOnOrderPromoAlert"
v-html="InvalidPromoOnOrderText" v-html="InvalidPromoOnOrderText"
@ -50,9 +50,7 @@ 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 { import { getVapsThatNeedToBeAddedToSatisfyPromos } from "@/helpers/promotions-helper";
getVapsThatNeedToBeAddedToSatisfyPromos,
} 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";
@ -181,53 +179,46 @@ export default {
); );
if (promoCodeData.isValid) { if (promoCodeData.isValid) {
const pricedLineItemsToTax = []; const pricedLineItemsToTax = [];
pricedLineItemsToTax.push(...promoCodeData.promoCode); pricedLineItemsToTax.push(...promoCodeData.promoCode);
const taxedLineItems = const taxedLineItems = await baseMixin.methods.dispatchStoreActionWithLogging(
await baseMixin.methods.dispatchStoreActionWithLogging( storeActions.TAX_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
storeActions.TAX_ORDER_ITEMS_AND_SAVE_SERVER_DATA, {
{ billToAccountNumber: "87291",
billToAccountNumber: "87291", providerNumber:
providerNumber: store.getters.order.serviceLocation.provider.providerNumber,
store.getters.order.serviceLocation.provider.providerNumber, appointmentType: store.getters.order.serviceLocation.appointmentType,
appointmentType: serviceLocationCity: store.getters.order.serviceLocation.city,
store.getters.order.serviceLocation.appointmentType, serviceLocationState: store.getters.order.serviceLocation.state,
serviceLocationCity: store.getters.order.serviceLocation.city, serviceLocationZipCode: store.getters.order.serviceLocation.zipCode,
serviceLocationState: store.getters.order.serviceLocation.state, pricedLineItems: pricedLineItemsToTax,
serviceLocationZipCode: },
store.getters.order.serviceLocation.zipCode, "payment-method",
pricedLineItems: pricedLineItemsToTax, false
}, );
"payment-method", // Match all line items to the line items as they are in the store
false // and rebuild the original structure.
); this.lineItems = mapTaxedLineItemsToStoreFormat(taxedLineItems, this.lineItems);
// Match all line items to the line items as they are in the store const taxedVaps = mapTaxedLineItemsToStoreFormat(
// and rebuild the original structure. taxedLineItems,
this.lineItems = mapTaxedLineItemsToStoreFormat( this.availableVaps
taxedLineItems, );
this.lineItems
);
const taxedVaps = mapTaxedLineItemsToStoreFormat(
taxedLineItems,
this.availableVaps
);
const getVaps = getVapsThatNeedToBeAddedToSatisfyPromos( const getVaps = getVapsThatNeedToBeAddedToSatisfyPromos(
promoCodeData.promoCode, promoCodeData.promoCode,
taxedVaps, taxedVaps,
this.lineItems this.lineItems
); );
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.$emit("update:modelValue", this.lineItems);
this.promoCode = ""; this.promoCode = "";
} else { } else {
if(promoCodeData.errorCode == "PromoStackingNotAllowed") if (promoCodeData.errorCode == "PromoStackingNotAllowed") {
{
this.displayInvalidPromoOnOrderAlert = true; this.displayInvalidPromoOnOrderAlert = true;
this.focusOnPromoInput(); this.focusOnPromoInput();
this.resetModalButtonStyle(); this.resetModalButtonStyle();
} }
this.displayInvalidPromoAlert = true; this.displayInvalidPromoAlert = true;
this.focusOnPromoInput(); this.focusOnPromoInput();