Update promo-modal-question.vue
This commit is contained in:
parent
3873c23716
commit
33d2db26d7
1 changed files with 40 additions and 49 deletions
|
|
@ -24,7 +24,7 @@
|
|||
cmsWidgetName="AlertInvalidPromoWidget"
|
||||
alertClass="alert-danger"
|
||||
v-bind:isDismissible="true" />
|
||||
<alert
|
||||
<alert
|
||||
ref="alertInvalidPromoOnOrder"
|
||||
v-if="displayInvalidOnOrderPromoAlert"
|
||||
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 alert from "@/ux-components/alert/alert";
|
||||
import { storeActions } from "@/constants/store-actions.js";
|
||||
import {
|
||||
getVapsThatNeedToBeAddedToSatisfyPromos,
|
||||
} from "@/helpers/promotions-helper";
|
||||
import { getVapsThatNeedToBeAddedToSatisfyPromos } from "@/helpers/promotions-helper";
|
||||
import { deepClone } from "@/helpers/object-helper";
|
||||
import baseMixin from "@/mixins/base-mixin.js";
|
||||
import { cartItemCategories } from "@/constants/cart-item-categories";
|
||||
|
|
@ -172,7 +170,7 @@ export default {
|
|||
async addPromoCode() {
|
||||
if (this.promoCode) {
|
||||
this.resetAlerts();
|
||||
|
||||
|
||||
const promoCodeData = await this.getPromoCodeData(
|
||||
this.promoCode,
|
||||
this.lineItems,
|
||||
|
|
@ -181,53 +179,46 @@ export default {
|
|||
);
|
||||
|
||||
if (promoCodeData.isValid) {
|
||||
const pricedLineItemsToTax = [];
|
||||
pricedLineItemsToTax.push(...promoCodeData.promoCode);
|
||||
const taxedLineItems =
|
||||
await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
storeActions.TAX_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
||||
{
|
||||
billToAccountNumber: "87291",
|
||||
providerNumber:
|
||||
store.getters.order.serviceLocation.provider.providerNumber,
|
||||
appointmentType:
|
||||
store.getters.order.serviceLocation.appointmentType,
|
||||
serviceLocationCity: store.getters.order.serviceLocation.city,
|
||||
serviceLocationState: store.getters.order.serviceLocation.state,
|
||||
serviceLocationZipCode:
|
||||
store.getters.order.serviceLocation.zipCode,
|
||||
pricedLineItems: pricedLineItemsToTax,
|
||||
},
|
||||
"payment-method",
|
||||
false
|
||||
);
|
||||
// Match all line items to the line items as they are in the store
|
||||
// and rebuild the original structure.
|
||||
this.lineItems = mapTaxedLineItemsToStoreFormat(
|
||||
taxedLineItems,
|
||||
this.lineItems
|
||||
);
|
||||
const taxedVaps = mapTaxedLineItemsToStoreFormat(
|
||||
taxedLineItems,
|
||||
this.availableVaps
|
||||
);
|
||||
const pricedLineItemsToTax = [];
|
||||
pricedLineItemsToTax.push(...promoCodeData.promoCode);
|
||||
const taxedLineItems = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
storeActions.TAX_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
||||
{
|
||||
billToAccountNumber: "87291",
|
||||
providerNumber:
|
||||
store.getters.order.serviceLocation.provider.providerNumber,
|
||||
appointmentType: store.getters.order.serviceLocation.appointmentType,
|
||||
serviceLocationCity: store.getters.order.serviceLocation.city,
|
||||
serviceLocationState: store.getters.order.serviceLocation.state,
|
||||
serviceLocationZipCode: store.getters.order.serviceLocation.zipCode,
|
||||
pricedLineItems: pricedLineItemsToTax,
|
||||
},
|
||||
"payment-method",
|
||||
false
|
||||
);
|
||||
// Match all line items to the line items as they are in the store
|
||||
// and rebuild the original structure.
|
||||
this.lineItems = mapTaxedLineItemsToStoreFormat(taxedLineItems, this.lineItems);
|
||||
const taxedVaps = mapTaxedLineItemsToStoreFormat(
|
||||
taxedLineItems,
|
||||
this.availableVaps
|
||||
);
|
||||
|
||||
const getVaps = getVapsThatNeedToBeAddedToSatisfyPromos(
|
||||
promoCodeData.promoCode,
|
||||
taxedVaps,
|
||||
this.lineItems
|
||||
);
|
||||
this.lineItems?.promos.push(...promoCodeData.promoCode);
|
||||
this.lineItems.vaps?.push(...getVaps);
|
||||
this.closeModal();
|
||||
this.$emit("update:modelValue", this.lineItems);
|
||||
this.promoCode = "";
|
||||
const getVaps = getVapsThatNeedToBeAddedToSatisfyPromos(
|
||||
promoCodeData.promoCode,
|
||||
taxedVaps,
|
||||
this.lineItems
|
||||
);
|
||||
this.lineItems?.promos.push(...promoCodeData.promoCode);
|
||||
this.lineItems.vaps?.push(...getVaps);
|
||||
this.closeModal();
|
||||
this.$emit("update:modelValue", this.lineItems);
|
||||
this.promoCode = "";
|
||||
} else {
|
||||
if(promoCodeData.errorCode == "PromoStackingNotAllowed")
|
||||
{
|
||||
if (promoCodeData.errorCode == "PromoStackingNotAllowed") {
|
||||
this.displayInvalidPromoOnOrderAlert = true;
|
||||
this.focusOnPromoInput();
|
||||
this.resetModalButtonStyle();
|
||||
this.focusOnPromoInput();
|
||||
this.resetModalButtonStyle();
|
||||
}
|
||||
this.displayInvalidPromoAlert = true;
|
||||
this.focusOnPromoInput();
|
||||
|
|
|
|||
Loading…
Reference in a new issue