CSR-1393
This commit is contained in:
parent
189350f1e9
commit
b7f46e877f
4 changed files with 84 additions and 45 deletions
|
|
@ -30,7 +30,7 @@
|
|||
@cart-remove="cartRemove"
|
||||
recyclingModalCmsWidgetName="RecycleModal" />
|
||||
|
||||
<hr class="my-5"/>
|
||||
<hr class="my-5" />
|
||||
<promoModalQuestion
|
||||
v-model="lineItems"
|
||||
:availableLineItems="availableLineItems"
|
||||
|
|
|
|||
|
|
@ -16,16 +16,14 @@
|
|||
customInputId="promoCode"
|
||||
v-model="promoCode"
|
||||
cmsWidgetName="PromoQuestionWidget" />
|
||||
<div
|
||||
v-for="(promo, i) in this.lineItems?.promos"
|
||||
:key="i">
|
||||
<span>Promo code "{{ promo?.promoCode }}" applied</span>
|
||||
<textLink
|
||||
ref="removeLink"
|
||||
linkType="text"
|
||||
:text="removeLinkText"
|
||||
href="#!"
|
||||
@click-event="removeItem()" />
|
||||
<div v-for="(promos,i) in this.lineItems?.promos" :key="i">
|
||||
<span class="applied-promo">Promo code "{{ promos }}" applied </span>
|
||||
<textLink
|
||||
ref="removeLink"
|
||||
linkType="text"
|
||||
:text="removeLinkText"
|
||||
href="#!"
|
||||
@click-event="removeItem()" />
|
||||
</div>
|
||||
<alert
|
||||
ref="alertInvalidPromo"
|
||||
|
|
@ -43,29 +41,26 @@ import textLink from "@/ux-components/text-link/text-link";
|
|||
import promoQuestion from "@/layouts/payment-method/promo-modal-question/promo-question/promo-question";
|
||||
import modal from "@/digital-components/modal/modal";
|
||||
import alert from "@/ux-components/alert/alert";
|
||||
import { processIfStatements } from "@/helpers/cms-content-helper";
|
||||
import store from "@/store";
|
||||
import { deepClone } from "@/helpers/object-helper";
|
||||
import {
|
||||
getAddableVapsFromAvailableLineItems,
|
||||
} from "@/helpers/promotions-helper";
|
||||
import { storeActions } from "@/constants/store-actions.js";
|
||||
import { getVapsThatNeedToBeAddedToSatisfyPromos,getAddableVapsFromAvailableLineItems } from "@/helpers/promotions-helper";
|
||||
|
||||
export default {
|
||||
name: "promo-modal-question",
|
||||
|
||||
data() {
|
||||
return {
|
||||
promoCode: [],
|
||||
promoCode: "",
|
||||
promoTextInputId: "",
|
||||
displayInvalidPromoAlert: false,
|
||||
lineItems:deepClone(this.modelValue),
|
||||
lineItems: deepClone(this.modelValue),
|
||||
};
|
||||
},
|
||||
props: {
|
||||
modelValue: Object,
|
||||
linkWidgetName: String,
|
||||
modalWidgetName: String,
|
||||
availableLineItems:Object,
|
||||
availableLineItems: Object,
|
||||
},
|
||||
|
||||
computed: {
|
||||
|
|
@ -98,7 +93,6 @@ export default {
|
|||
},
|
||||
},
|
||||
methods: {
|
||||
processIfStatements,
|
||||
resetAlerts() {
|
||||
this.displayInvalidPromoAlert = false;
|
||||
},
|
||||
|
|
@ -119,25 +113,56 @@ export default {
|
|||
this.modal.resetButtonStyle();
|
||||
},
|
||||
getPromoAddedMessage() {
|
||||
return this.processIfStatements(
|
||||
this.AddPromoSuccessMessageFromCms,
|
||||
"custom",
|
||||
this.promoCode
|
||||
return this.AddPromoSuccessMessageFromCms?.replaceAll("{custom}", this.promoCode);
|
||||
},
|
||||
async getPromoCodeData(promoCode, lineItems, availableLineItems, pageNameToLog = null) {
|
||||
const pageName = pageNameToLog ?? this.$options?.name;
|
||||
const addableVaps = getAddableVapsFromAvailableLineItems(availableLineItems);
|
||||
const promoValidationResponse = await this.dispatchStoreActionWithLogging(
|
||||
storeActions.VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA,
|
||||
{
|
||||
promoCode: promoCode,
|
||||
lineItemsToUse: lineItems,
|
||||
addableVaps: addableVaps,
|
||||
},
|
||||
pageName
|
||||
);
|
||||
|
||||
return {
|
||||
isValid: !("errorCode" in promoValidationResponse),
|
||||
promoCode: promoValidationResponse?.orderPromos,
|
||||
errorCode: promoValidationResponse?.errorCode,
|
||||
};
|
||||
},
|
||||
async addPromoCode() {
|
||||
if (this.promoCode) {
|
||||
this.resetAlerts();
|
||||
const lineItems = store.getters.order.lineItems;
|
||||
const getVaps = getAddableVapsFromAvailableLineItems(this.availableLineItems)
|
||||
lineItems.vaps?.push(getVaps);
|
||||
const promoCodeData = await this.getPromoCodeData(this.promoCode,this.lineItems,this.availableLineItems, "payment-method");
|
||||
// const getVaps = getVapsThatNeedToBeAddedToSatisfyPromos(
|
||||
// this.promoCode,
|
||||
// this.availableLineItems,
|
||||
// this.lineItems
|
||||
// );
|
||||
// this.lineItems.vaps?.push(getVaps);
|
||||
|
||||
const promoCodeData = await this.getPromoCodeData(
|
||||
this.promoCode,
|
||||
this.lineItems,
|
||||
this.availableLineItems,
|
||||
"payment-method"
|
||||
);
|
||||
|
||||
if (promoCodeData.isValid) {
|
||||
let promos = [];
|
||||
promos.push(promoCodeData.promoCode);
|
||||
const modelValue = this.modelValue;
|
||||
modelValue.promos = promos;
|
||||
this.closeModal();
|
||||
// const getVaps = getVapsThatNeedToBeAddedToSatisfyPromos(
|
||||
// this.promoCode,
|
||||
// this.availableLineItems,
|
||||
// this.lineItems
|
||||
// );
|
||||
// this.lineItems.vaps?.push(getVaps);
|
||||
const message = this.getPromoAddedMessage();
|
||||
this.$emit("added-to-cart", {
|
||||
messageHeadline: "Promo Applied!",
|
||||
|
|
@ -169,3 +194,14 @@ export default {
|
|||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.applied-promo {
|
||||
padding-right: 7rem;
|
||||
font-family: Roboto;
|
||||
font-size: 14px;
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
line-height: 24px;
|
||||
color:#0C7E47;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -25,9 +25,7 @@ defineRule("promo-required", required(errorMessages.PROMO_REQUIRED));
|
|||
export default {
|
||||
name: "promo-question",
|
||||
props: {
|
||||
modelValue: {
|
||||
promoCode: String,
|
||||
},
|
||||
modelValue:String,
|
||||
cmsWidgetName: String,
|
||||
},
|
||||
computed: {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { routerParams } from "@/router/router-constants/router-params";
|
|||
import { queryStrings } from "@/constants/query-strings";
|
||||
import { dynamicStrings } from "@/constants/dynamic-strings";
|
||||
import { partTypeStrings } from "../constants/part-type-strings";
|
||||
//import { getAddableVapsFromAvailableLineItems } from "@/helpers/promotions-helper";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
|
|
@ -80,21 +81,25 @@ export default {
|
|||
zipCodeCtu: serviceZipValidationResponse.data.zipCodeCtu,
|
||||
};
|
||||
},
|
||||
async getPromoCodeData(promoCode,lineItems,availableLineItems, pageNameToLog = null) {
|
||||
const pageName = pageNameToLog ?? this.$options?.name;
|
||||
// async getPromoCodeData(promoCode, lineItems, availableLineItems, pageNameToLog = null) {
|
||||
// const pageName = pageNameToLog ?? this.$options?.name;
|
||||
// const addableVaps = getAddableVapsFromAvailableLineItems(availableLineItems);
|
||||
// const promoValidationResponse = await this.dispatchStoreActionWithLogging(
|
||||
// storeActions.VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA,
|
||||
// {
|
||||
// promoCode: promoCode,
|
||||
// lineItemsToUse: lineItems,
|
||||
// addableVaps: addableVaps,
|
||||
// },
|
||||
// pageName
|
||||
// );
|
||||
|
||||
const promoValidationResponse = await this.dispatchStoreActionWithLogging(
|
||||
storeActions.VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA,
|
||||
{ promoCode: promoCode ,lineItems:lineItems,availableLineItems:availableLineItems},
|
||||
pageName
|
||||
);
|
||||
|
||||
return {
|
||||
isValid: !("errorCode" in promoValidationResponse),
|
||||
promoCode: promoValidationResponse?.orderPromos,
|
||||
errorCode: promoValidationResponse?.errorCode,
|
||||
};
|
||||
},
|
||||
// return {
|
||||
// isValid: !("errorCode" in promoValidationResponse),
|
||||
// promoCode: promoValidationResponse?.orderPromos,
|
||||
// errorCode: promoValidationResponse?.errorCode,
|
||||
// };
|
||||
// },
|
||||
getTierOnePackagePrice(lineItems) {
|
||||
let lineItemsToPrice = lineItems.filter((lineItem) => {
|
||||
return (
|
||||
|
|
|
|||
Loading…
Reference in a new issue