Merge branch 'develop' into feature/CSR-1392
This commit is contained in:
commit
b8bd1e4b0b
17 changed files with 368 additions and 107 deletions
|
|
@ -87,6 +87,20 @@
|
|||
display: none;
|
||||
}
|
||||
|
||||
.buy-backdrop {
|
||||
background-color: rgba(0, 0, 0, 0.3) !important;
|
||||
}
|
||||
.buy-backdrop #afterpay__iframe-checkout-container {
|
||||
width: 100%;
|
||||
}
|
||||
.buy-backdrop #afterpay__iframe-checkout-container .style_closeWrapper__lIHJe {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.buy-container-closer {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@keyframes rotate {
|
||||
0% {
|
||||
transform: rotate(0);
|
||||
|
|
|
|||
|
|
@ -90,6 +90,24 @@
|
|||
}
|
||||
}
|
||||
|
||||
// AfterPay Styles
|
||||
|
||||
.buy-backdrop {
|
||||
background-color: rgba(0,0,0,.3)!important;
|
||||
#afterpay__iframe-checkout-container {
|
||||
width: 100%;
|
||||
.style_closeWrapper__lIHJe {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.buy-container-closer {
|
||||
display: none;
|
||||
}
|
||||
|
||||
// Modal Spinner
|
||||
|
||||
@keyframes rotate {
|
||||
0% { transform: rotate(0)}
|
||||
100% { transform: rotate(360deg)}
|
||||
|
|
|
|||
|
|
@ -37,13 +37,13 @@ describe("cart.vue", () => {
|
|||
promos: [],
|
||||
};
|
||||
|
||||
const availableLineItems = [];
|
||||
const availableVaps = [];
|
||||
|
||||
// Act
|
||||
const { wrapper } = setupMocks({
|
||||
props: {
|
||||
modelValue: lineItems,
|
||||
availableLineItems: availableLineItems,
|
||||
availableVaps: availableVaps,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -89,13 +89,13 @@ describe("cart.vue", () => {
|
|||
promos: [],
|
||||
};
|
||||
|
||||
const availableLineItems = [];
|
||||
const availableVaps = [];
|
||||
|
||||
// Act
|
||||
const { wrapper } = setupMocks({
|
||||
props: {
|
||||
modelValue: lineItems,
|
||||
availableLineItems: availableLineItems,
|
||||
availableVaps: availableVaps,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -132,13 +132,13 @@ describe("cart.vue", () => {
|
|||
promos: [],
|
||||
};
|
||||
|
||||
const availableLineItems = [];
|
||||
const availableVaps = [];
|
||||
|
||||
// Act
|
||||
const { wrapper } = setupMocks({
|
||||
props: {
|
||||
modelValue: lineItems,
|
||||
availableLineItems: availableLineItems,
|
||||
availableVaps: availableVaps,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -189,13 +189,13 @@ describe("cart.vue", () => {
|
|||
// promos: [],
|
||||
// };
|
||||
|
||||
// const availableLineItems = [];
|
||||
// const availableVaps = [];
|
||||
|
||||
// // Act
|
||||
// const { wrapper } = setupMocks({
|
||||
// props: {
|
||||
// modelValue: lineItems,
|
||||
// availableLineItems: availableLineItems,
|
||||
// availableVaps: availableVaps,
|
||||
// },
|
||||
// });
|
||||
|
||||
|
|
@ -234,13 +234,13 @@ describe("cart.vue", () => {
|
|||
promos: [],
|
||||
};
|
||||
|
||||
const availableLineItems = [];
|
||||
const availableVaps = [];
|
||||
|
||||
// Act
|
||||
const { wrapper } = setupMocks({
|
||||
props: {
|
||||
modelValue: lineItems,
|
||||
availableLineItems: availableLineItems,
|
||||
availableVaps: availableVaps,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -277,13 +277,13 @@ describe("cart.vue", () => {
|
|||
promos: [],
|
||||
};
|
||||
|
||||
const availableLineItems = [];
|
||||
const availableVaps = [];
|
||||
|
||||
// Act
|
||||
const { wrapper } = setupMocks({
|
||||
props: {
|
||||
modelValue: lineItems,
|
||||
availableLineItems: availableLineItems,
|
||||
availableVaps: availableVaps,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -321,13 +321,13 @@ describe("cart.vue", () => {
|
|||
promos: [],
|
||||
};
|
||||
|
||||
const availableLineItems = [];
|
||||
const availableVaps = [];
|
||||
|
||||
// Act
|
||||
const { wrapper } = setupMocks({
|
||||
props: {
|
||||
modelValue: lineItems,
|
||||
availableLineItems: availableLineItems,
|
||||
availableVaps: availableVaps,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<div class="cart mb-4">
|
||||
<div class="cart mb-5">
|
||||
<div class="px-0">
|
||||
<div
|
||||
class="row vin-toggle flex align-items-center"
|
||||
|
|
@ -33,7 +33,6 @@
|
|||
</div>
|
||||
|
||||
<!-- Nonpackaged Cart Items -->
|
||||
<hr style="background: red" />
|
||||
<div
|
||||
class="premium-appt-cart-item"
|
||||
v-for="(cartItem, i) in nonpackageCartItems"
|
||||
|
|
@ -128,7 +127,7 @@ export default {
|
|||
modelValue: Object,
|
||||
damage: Object,
|
||||
servicePackageOptionsCmsName: String,
|
||||
availableLineItems: Object,
|
||||
availableVaps: Object,
|
||||
allowItemRemoval: Boolean,
|
||||
recyclingModalCmsWidgetName: String,
|
||||
},
|
||||
|
|
@ -201,6 +200,16 @@ export default {
|
|||
},
|
||||
},
|
||||
computed: {
|
||||
availableLineItems() {
|
||||
if (!this.lineItems || this.lineItems.length < 1) {
|
||||
return [];
|
||||
}
|
||||
return [
|
||||
...this.lineItems.glassParts,
|
||||
...this.lineItems.supportingItems,
|
||||
...this.availableVaps,
|
||||
];
|
||||
},
|
||||
cartItems: {
|
||||
get: function () {
|
||||
let cartItems = [];
|
||||
|
|
@ -802,4 +811,12 @@ export default {
|
|||
}
|
||||
}
|
||||
}
|
||||
.payment-method-question {
|
||||
.question-text {
|
||||
margin: 1rem 0 0.5rem 0;
|
||||
}
|
||||
span {
|
||||
line-height: 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import store from "@/store";
|
||||
import { storeActions } from "@/constants/store-actions";
|
||||
import { partTypeStrings } from "@/constants/part-type-strings";
|
||||
import { deepClone } from "@/helpers/object-helper";
|
||||
import baseMixin from "@/mixins/base-mixin.js";
|
||||
|
||||
export const promoPartNumberStrings = {
|
||||
|
|
@ -126,6 +127,31 @@ export function getPromosThatMatchLineItemsOnOrder(promos, lineItemsOnOrder) {
|
|||
return matchingPromos;
|
||||
}
|
||||
|
||||
// Returns the vaps that the provided <promos> requires to be on the order to satisfy
|
||||
// Items that are already in <lineItemsOnOrder> will not be returned
|
||||
export function getVapsThatNeedToBeAddedToSatisfyPromos(
|
||||
promos,
|
||||
availableLineItems,
|
||||
lineItemsOnOrder
|
||||
) {
|
||||
const clonedVaps = deepClone(lineItemsOnOrder.vaps ?? []);
|
||||
const promosWithAddableVaps = getPromosWithAddableVaps(promos);
|
||||
if (promosWithAddableVaps.length) {
|
||||
const matchingLineItems = getLineItemsThatMatchPromos(
|
||||
promosWithAddableVaps,
|
||||
availableLineItems
|
||||
);
|
||||
// Check if matching items are already in the order
|
||||
const idsOfVapsAlreadyInOrder = clonedVaps.map((lineItem) => lineItem.id);
|
||||
const vapsToAddToCart = matchingLineItems.filter(
|
||||
(lineItem) => !idsOfVapsAlreadyInOrder.includes(lineItem.id)
|
||||
);
|
||||
return vapsToAddToCart;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export function shouldStripPromoQueryString(fmgPageQueryValue) {
|
||||
return pagesToStripPromoQueryStringFrom.includes(fmgPageQueryValue);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
<div>
|
||||
<vehicleBanner
|
||||
cmsWidgetName="VehicleBannerWidget"
|
||||
:displayVehicleImage="vehicleBannerImageUrl"
|
||||
:displayGenericVehicleImage="false" />
|
||||
</div>
|
||||
<div class="scheduleText">
|
||||
|
|
@ -205,6 +206,9 @@ export default {
|
|||
return `at ${get12HourTimeFormat(this.ScheduleStartTime)}`;
|
||||
}
|
||||
},
|
||||
vehicleBannerImageUrl() {
|
||||
return store.getters.submittedOrder?.vehicle.imageUrl;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
arePagePrerequisitesValid() {
|
||||
|
|
@ -238,7 +242,11 @@ export default {
|
|||
const schedule = store.getters.order.schedule;
|
||||
const scheduleReqs = !!(schedule.date && schedule.startTime && schedule.endTime);
|
||||
|
||||
return serviceLocationReqs && scheduleReqs;
|
||||
// Customer
|
||||
const customer = store.getters.order.customer;
|
||||
const customerReqs = !!customer.emailAddress;
|
||||
|
||||
return serviceLocationReqs && scheduleReqs && customerReqs;
|
||||
},
|
||||
forwardButtonAction() {
|
||||
window.location.assign("//www.safelite.com/");
|
||||
|
|
|
|||
|
|
@ -76,13 +76,12 @@ export default {
|
|||
name: "add-vaps-modal-buttons",
|
||||
props: {
|
||||
vapsTilesCmsName: String,
|
||||
availableLineItems: Object,
|
||||
availableVaps: Object,
|
||||
modelValue: Object,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
addVapsButton: addVapsButton,
|
||||
wipersOffered: null,
|
||||
isModalOpened: false,
|
||||
selectedWipers: this.getSelectedWipers(),
|
||||
};
|
||||
|
|
@ -97,7 +96,11 @@ export default {
|
|||
this.$refs[modalName].closeModal();
|
||||
},
|
||||
addRainDefenseToCart(modalName, part) {
|
||||
this.currentCartItems.vaps.push(part);
|
||||
// Clone vaps array, then replace this.currentCartItems.vaps with it at the end
|
||||
// in order to successfully trigger parent's watcher
|
||||
const clonedVaps = this.currentCartItems.vaps.slice(0);
|
||||
clonedVaps.push(part);
|
||||
this.currentCartItems.vaps = clonedVaps;
|
||||
this.closeModal(modalName);
|
||||
const message = this.getRainDefenseAddedMessage();
|
||||
this.$emit("added-to-cart", {
|
||||
|
|
@ -133,19 +136,23 @@ export default {
|
|||
this.selectedWipers = ["REAR"];
|
||||
}
|
||||
}
|
||||
// Clone vaps array, then replace this.currentCartItems.vaps with it at the end
|
||||
// in order to successfully trigger parent's watcher
|
||||
const clonedVaps = this.currentCartItems.vaps.slice(0);
|
||||
|
||||
itemsForCart.forEach((type) => {
|
||||
if (type === wipersOfferedStrings.FRONT) {
|
||||
part.frontWiperLineItems.forEach((part) => {
|
||||
this.currentCartItems.vaps.push(part);
|
||||
clonedVaps.push(part);
|
||||
});
|
||||
}
|
||||
if (type === wipersOfferedStrings.REAR) {
|
||||
part.rearWiperLineItems.forEach((part) => {
|
||||
this.currentCartItems.vaps.push(part);
|
||||
clonedVaps.push(part);
|
||||
});
|
||||
}
|
||||
});
|
||||
this.currentCartItems.vaps = clonedVaps;
|
||||
|
||||
this.closeModal(modalName);
|
||||
|
||||
|
|
@ -198,7 +205,7 @@ export default {
|
|||
return modelValue;
|
||||
},
|
||||
rainDefenseModal() {
|
||||
const lineItem = this.availableLineItems.find((item) => {
|
||||
const lineItem = this.availableVaps.find((item) => {
|
||||
return item.partType === partTypeStrings.RAIN_DEFENSE;
|
||||
});
|
||||
if (lineItem)
|
||||
|
|
@ -209,10 +216,10 @@ export default {
|
|||
},
|
||||
wipersModal() {
|
||||
// create a single wiper item for modal
|
||||
const frontWiperLineItems = this.availableLineItems.filter((item) => {
|
||||
const frontWiperLineItems = this.availableVaps.filter((item) => {
|
||||
return item.partType.includes(partTypeStrings.FRONT_WIPER);
|
||||
});
|
||||
const rearWiperLineItems = this.availableLineItems.filter((item) => {
|
||||
const rearWiperLineItems = this.availableVaps.filter((item) => {
|
||||
return item.partType.includes(partTypeStrings.REAR_WIPER);
|
||||
});
|
||||
let wipersModal;
|
||||
|
|
@ -241,20 +248,38 @@ export default {
|
|||
answersCmsData() {
|
||||
return this.getCmsContent(this.vapsTilesCmsName, "Answers");
|
||||
},
|
||||
rainDefenseInCart() {
|
||||
return this.currentCartItems.vaps?.some((vap) => {
|
||||
return vap?.partType === partTypeStrings.RAIN_DEFENSE;
|
||||
});
|
||||
},
|
||||
frontWipersInCart() {
|
||||
return this.currentCartItems.vaps?.some((vap) => {
|
||||
return vap?.partType?.includes(partTypeStrings.FRONT_WIPER);
|
||||
});
|
||||
},
|
||||
rearWipersInCart() {
|
||||
return this.currentCartItems.vaps?.some((vap) => {
|
||||
return vap?.partType?.includes(partTypeStrings.REAR_WIPER);
|
||||
});
|
||||
},
|
||||
wipersOffered() {
|
||||
let result;
|
||||
if (!this.frontWipersInCart) {
|
||||
if (!this.rearWipersInCart && this.wipersModal?.rearWiperLineItems.length > 0) {
|
||||
result = wipersOfferedStrings.BOTH;
|
||||
} else {
|
||||
result = wipersOfferedStrings.FRONT;
|
||||
}
|
||||
} else if (!this.rearWipersInCart && this.wipersModal?.rearWiperLineItems.length > 0) {
|
||||
result = wipersOfferedStrings.REAR;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
buttonsToDisplay() {
|
||||
const buttons = [];
|
||||
if (!this.answersCmsData) return buttons;
|
||||
|
||||
const rainDefenseInCart = this.currentCartItems.vaps?.some((vap) => {
|
||||
return vap?.partType === partTypeStrings.RAIN_DEFENSE;
|
||||
});
|
||||
const frontWipersInCart = this.currentCartItems.vaps?.some((vap) => {
|
||||
return vap?.partType?.includes(partTypeStrings.FRONT_WIPER);
|
||||
});
|
||||
const rearWipersInCart = this.currentCartItems.vaps?.some((vap) => {
|
||||
return vap?.partType?.includes(partTypeStrings.REAR_WIPER);
|
||||
});
|
||||
|
||||
const getAnswer = (name, answers) => {
|
||||
const answerIndex = answers.findIndex((answer) => {
|
||||
return answer.Name === name;
|
||||
|
|
@ -262,7 +287,7 @@ export default {
|
|||
return answers[answerIndex];
|
||||
};
|
||||
|
||||
if (!rainDefenseInCart) {
|
||||
if (!this.rainDefenseInCart) {
|
||||
// NO RAIN DEFENSE IN CART; SHOW RAIN DEFENSE BUTTON
|
||||
const modalData = getAnswer("RainDefenseModal", this.answersCmsData);
|
||||
modalData.SubText = "+$" + this.rainDefenseModal?.listPrice;
|
||||
|
|
@ -270,27 +295,26 @@ export default {
|
|||
}
|
||||
|
||||
const modalData = getAnswer("WipersModal", this.answersCmsData);
|
||||
if (!frontWipersInCart) {
|
||||
if (!rearWipersInCart && this.wipersModal?.rearWiperLineItems.length > 0) {
|
||||
// NO REAR WIPERS or FRONT WIPERS IN CART; SHOW COMBO BUTTON
|
||||
const prices = [
|
||||
this.wipersModal?.totalFrontPrice,
|
||||
this.wipersModal?.totalRearPrice,
|
||||
];
|
||||
prices.sort((a, b) => a - b);
|
||||
modalData.SubText = "+$" + prices[0] + " - $" + prices[prices.length - 1];
|
||||
this.updateWipersOffered(wipersOfferedStrings.BOTH);
|
||||
buttons.push(modalData);
|
||||
} else {
|
||||
// NO FRONT WIPERS IN CART; SHOW ONLY FRONT WIPERS BUTTON
|
||||
modalData.SubText = "+$" + this.wipersModal?.totalFrontPrice;
|
||||
this.updateWipersOffered(wipersOfferedStrings.FRONT);
|
||||
buttons.push(modalData);
|
||||
}
|
||||
} else if (!rearWipersInCart && this.wipersModal?.rearWiperLineItems.length > 0) {
|
||||
if (this.wipersOffered === wipersOfferedStrings.BOTH) {
|
||||
// NO REAR WIPERS or FRONT WIPERS IN CART; SHOW COMBO BUTTON
|
||||
const prices = [
|
||||
this.wipersModal?.totalFrontPrice,
|
||||
this.wipersModal?.totalRearPrice,
|
||||
];
|
||||
prices.sort((a, b) => a - b);
|
||||
modalData.SubText = "+$" + prices[0] + " - $" + prices[prices.length - 1];
|
||||
buttons.push(modalData);
|
||||
}
|
||||
|
||||
if (this.wipersOffered === wipersOfferedStrings.FRONT) {
|
||||
// NO FRONT WIPERS IN CART; SHOW ONLY FRONT WIPERS BUTTON
|
||||
modalData.SubText = "+$" + this.wipersModal?.totalFrontPrice;
|
||||
buttons.push(modalData);
|
||||
}
|
||||
|
||||
if (this.wipersOffered === wipersOfferedStrings.REAR) {
|
||||
// NO REAR WIPERS IN CART; SHOW ONLY REAR WIPERS BUTTON
|
||||
modalData.SubText = "+$" + this.wipersModal?.totalRearPrice;
|
||||
this.updateWipersOffered(wipersOfferedStrings.REAR);
|
||||
buttons.push(modalData);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ export default {
|
|||
.payment-method-question {
|
||||
.question-text span {
|
||||
text-align: left;
|
||||
line-height: 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -23,14 +23,14 @@
|
|||
|
||||
<cart
|
||||
:damage="damageInfo"
|
||||
:availableLineItems="availableLineItems"
|
||||
:availableVaps="availableVaps"
|
||||
:allowItemRemoval="true"
|
||||
v-model="lineItems"
|
||||
servicePackageOptionsCmsName="ServicePackageTitle"
|
||||
@cart-remove="cartRemove"
|
||||
recyclingModalCmsWidgetName="RecycleModal" />
|
||||
|
||||
<hr />
|
||||
<hr class="my-5" />
|
||||
|
||||
<div>
|
||||
<alert
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
<add-vaps-modal-buttons
|
||||
v-model="lineItems"
|
||||
:availableLineItems="availableLineItems"
|
||||
:availableVaps="availableVaps"
|
||||
vapsTilesCmsName="VapsProductTiles"
|
||||
@added-to-cart="showAlert" />
|
||||
|
||||
|
|
@ -88,17 +88,19 @@ import { paymentMethods } from "@/constants/payment-method-constants";
|
|||
import { experimentSettings } from "@/constants/experiments";
|
||||
import {
|
||||
revalidatePromosAndValidateNewPromo,
|
||||
getAddableVapsFromAvailableLineItems,
|
||||
getPromosWithAddableVaps,
|
||||
getVapsThatNeedToBeAddedToSatisfyPromos,
|
||||
} from "@/helpers/promotions-helper";
|
||||
import { queryStrings } from "@/constants/query-strings";
|
||||
import { getQuerystringParameter } from "@/helpers/querystring-helper";
|
||||
import { deepClone } from "@/helpers/object-helper";
|
||||
|
||||
import { Form } from "vee-validate";
|
||||
import { defineRule } from "vee-validate";
|
||||
import { required } from "@/helpers/validation-rules";
|
||||
import { errorMessages } from "@/constants/error-messages";
|
||||
import { AppointmentTypeStrings } from "@/constants/schedule-constants";
|
||||
import { mapTaxedAvailableLineItemsToStoreFormat } from "../../store";
|
||||
import { mapTaxedLineItemsToStoreFormat } from "../../store";
|
||||
|
||||
defineRule("option-required", required(errorMessages.OPTION_REQUIRED));
|
||||
|
||||
|
|
@ -120,12 +122,6 @@ export default {
|
|||
"payment-method"
|
||||
);
|
||||
|
||||
const supportingItemsPromise = baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
storeActions.GET_SUPPORTING_ITEMS,
|
||||
null,
|
||||
"payment-method"
|
||||
);
|
||||
|
||||
const promiseResultMap = [
|
||||
{
|
||||
resultKey: "cmsContent",
|
||||
|
|
@ -139,29 +135,25 @@ export default {
|
|||
resultKey: "rainDefense",
|
||||
promise: rainDefensePromise,
|
||||
},
|
||||
{
|
||||
resultKey: "supportingItems",
|
||||
promise: supportingItemsPromise,
|
||||
},
|
||||
];
|
||||
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
const lineItemsFromStore = deepClone(store.getters.order.lineItems);
|
||||
const glassParts = lineItemsFromStore.glassParts ?? [];
|
||||
const supportingItems = lineItemsFromStore.supportingItems ?? [];
|
||||
|
||||
const glassParts = store.getters.order.lineItems.glassParts ?? [];
|
||||
|
||||
let availableLineItems = [
|
||||
const lineItemsToTax = [
|
||||
resultMap.rainDefense,
|
||||
...resultMap.supportingItems,
|
||||
...supportingItems,
|
||||
...resultMap.wipers,
|
||||
...glassParts,
|
||||
];
|
||||
const availableVaps = [resultMap.rainDefense, ...resultMap.wipers];
|
||||
|
||||
const lineItemsFromStore = store.getters.order.lineItems;
|
||||
|
||||
await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
const pricedLineItemsToTax = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
||||
{
|
||||
availableLineItems: availableLineItems,
|
||||
availableLineItems: lineItemsToTax,
|
||||
},
|
||||
"payment-method",
|
||||
false
|
||||
|
|
@ -173,14 +165,16 @@ export default {
|
|||
const { validatePromoResponse, revalidatePromoResponse } =
|
||||
await revalidatePromosAndValidateNewPromo(
|
||||
promoCodeFromQueryString,
|
||||
availableLineItems,
|
||||
pricedLineItemsToTax,
|
||||
"payment-method"
|
||||
);
|
||||
|
||||
availableLineItems.push(...(validatePromoResponse?.orderPromos ?? []));
|
||||
const newValidatedPromos = validatePromoResponse?.orderPromos ?? [];
|
||||
|
||||
pricedLineItemsToTax.push(...newValidatedPromos);
|
||||
// End of promo logic
|
||||
|
||||
const taxedAvailableLineItems = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
const taxedLineItems = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
storeActions.TAX_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
||||
{
|
||||
billToAccountNumber: "87291",
|
||||
|
|
@ -189,32 +183,39 @@ export default {
|
|||
serviceLocationCity: store.getters.order.serviceLocation.city,
|
||||
serviceLocationState: store.getters.order.serviceLocation.state,
|
||||
serviceLocationZipCode: store.getters.order.serviceLocation.zipCode,
|
||||
pricedAvailableLineItems: availableLineItems,
|
||||
pricedLineItems: pricedLineItemsToTax,
|
||||
},
|
||||
"payment-method",
|
||||
false
|
||||
);
|
||||
|
||||
// Match all available line items to the line items as they are in the store
|
||||
// Match all line items to the line items as they are in the store
|
||||
// and rebuild the original structure.
|
||||
const lineItems = mapTaxedAvailableLineItemsToStoreFormat(
|
||||
availableLineItems,
|
||||
lineItemsFromStore
|
||||
const lineItems = mapTaxedLineItemsToStoreFormat(taxedLineItems, lineItemsFromStore);
|
||||
const taxedVaps = mapTaxedLineItemsToStoreFormat(taxedLineItems, availableVaps);
|
||||
|
||||
// Add items that were not in the store yet but added via query string promo validation
|
||||
lineItems.promos = lineItems.promos ?? [];
|
||||
lineItems.promos.push(...newValidatedPromos);
|
||||
const vapsToAddToCart = getVapsThatNeedToBeAddedToSatisfyPromos(
|
||||
newValidatedPromos,
|
||||
taxedVaps,
|
||||
lineItems
|
||||
);
|
||||
lineItems.vaps.push(...vapsToAddToCart);
|
||||
|
||||
// Call the "next" function to complete the transition to this page.
|
||||
next((vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
vm.availableLineItems = taxedAvailableLineItems;
|
||||
vm.availableVaps = taxedVaps;
|
||||
vm.lineItems = lineItems;
|
||||
|
||||
vm.updateFooterButtonText(vm.customCtaCopy);
|
||||
});
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
lineItems: [],
|
||||
availableLineItems: [],
|
||||
availableVaps: [],
|
||||
paymentMethodInternalModel: this.getPaymentMethodFromStore(),
|
||||
inactivePromos: this.getInactivePromosFromStore(),
|
||||
};
|
||||
|
|
@ -254,7 +255,7 @@ export default {
|
|||
const scheduleReqs = !!(
|
||||
schedule.date &&
|
||||
schedule.startTime &&
|
||||
(!isMobile || schedule.endTime) &&
|
||||
schedule.endTime &&
|
||||
schedule.jobMaxMinutes &&
|
||||
schedule.jobMinMinutes
|
||||
);
|
||||
|
|
@ -397,10 +398,11 @@ export default {
|
|||
}
|
||||
},
|
||||
isPiaDisabled() {
|
||||
const piaExperience =
|
||||
this.getSettingValue(experimentSettings.PIA_EXPERIENCE) === "PIA Optional";
|
||||
const piaExperience = this.getSettingValue(experimentSettings.PIA_EXPERIENCE);
|
||||
|
||||
return !piaExperience;
|
||||
const isEnabled = piaExperience === "PIA Optional" || piaExperience === "PIA Required";
|
||||
|
||||
return !isEnabled;
|
||||
},
|
||||
paymentMethod() {
|
||||
if (this.isPiaDisabled) {
|
||||
|
|
@ -412,11 +414,35 @@ export default {
|
|||
shouldDisplayPiaAlert() {
|
||||
return this.$route.params[this.routerParams.DISPLAY_PIA_ALERT];
|
||||
},
|
||||
// Necessary to make the watcher of lineItems work
|
||||
// JavaScript does not keep a record of the old value, only a reference to it's location in the memory.
|
||||
// This creates a separate location for oldValue/newValue so they can be compared
|
||||
// See Vue github issue #2164
|
||||
lineItemsCloneForWatcher() {
|
||||
return Object.assign({}, this.lineItems);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
customCtaCopy(newValue) {
|
||||
this.updateFooterButtonText(newValue);
|
||||
},
|
||||
lineItemsCloneForWatcher: {
|
||||
handler(newValue, oldValue) {
|
||||
if (
|
||||
!oldValue ||
|
||||
oldValue.length == 0 ||
|
||||
!oldValue.vaps ||
|
||||
!newValue ||
|
||||
newValue.length == 0
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (oldValue.vaps.length != newValue.vaps.length) {
|
||||
this.revalidatePromos();
|
||||
}
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
},
|
||||
components: {
|
||||
funnelHeader,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,19 @@
|
|||
scrolling="no">
|
||||
</iframe>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<cart
|
||||
:damage="damageInfo"
|
||||
:availableLineItems="availableLineItems"
|
||||
:allowItemRemoval="false"
|
||||
v-model="lineItems"
|
||||
servicePackageOptionsCmsName="ServicePackageTitle"
|
||||
recyclingModalCmsWidgetName="RecycleModal" />
|
||||
|
||||
<hr />
|
||||
|
||||
<paymentSwitch
|
||||
cmsWidgetName="PaymentMethodWidget"
|
||||
:paymentType="paymentType"
|
||||
|
|
@ -163,7 +176,7 @@
|
|||
import funnelHeader from "@/fmg-components/funnel-header/funnel-header";
|
||||
import navbar from "@/fmg-components/nav-bar/nav-bar";
|
||||
import loadingModal from "@/fmg-components/loading-modal/loading-modal.vue";
|
||||
|
||||
import cart from "@/fmg-components/cart/cart";
|
||||
import paymentSwitch from "./payment-switch/payment-switch.vue";
|
||||
|
||||
import { storeActions } from "@/constants/store-actions";
|
||||
|
|
@ -175,6 +188,13 @@ import { applicationConfig } from "@/constants/application-config";
|
|||
import { paymentMethods } from "@/constants/payment-method-constants";
|
||||
import { AppointmentTypeStrings } from "@/constants/schedule-constants";
|
||||
import baseMixin from "@/mixins/base-mixin.js";
|
||||
import { mapTaxedLineItemsToStoreFormat } from "../../store";
|
||||
import {
|
||||
revalidatePromosAndValidateNewPromo,
|
||||
getAddableVapsFromAvailableLineItems,
|
||||
} from "@/helpers/promotions-helper";
|
||||
import { queryStrings } from "@/constants/query-strings";
|
||||
import { getQuerystringParameter } from "@/helpers/querystring-helper";
|
||||
|
||||
import iframeResize from "../../../node_modules/iframe-resizer/js/iframeResizer.js";
|
||||
|
||||
|
|
@ -207,6 +227,8 @@ export default {
|
|||
displayAmount: this.getDisplayAmountDue(),
|
||||
piaLineItems: this.getPiaLineItems(),
|
||||
paypalPayment: this.isPaypal(),
|
||||
lineItems: [],
|
||||
availableLineItems: [],
|
||||
};
|
||||
},
|
||||
directives: {
|
||||
|
|
@ -231,6 +253,24 @@ export default {
|
|||
"payment"
|
||||
);
|
||||
|
||||
const wipersPromise = baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
storeActions.GET_WIPERS,
|
||||
null,
|
||||
"payment"
|
||||
);
|
||||
|
||||
const rainDefensePromise = baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
storeActions.GET_RAIN_DEFENSE,
|
||||
null,
|
||||
"payment"
|
||||
);
|
||||
|
||||
const supportingItemsPromise = baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
storeActions.GET_SUPPORTING_ITEMS,
|
||||
null,
|
||||
"payment"
|
||||
);
|
||||
|
||||
// TODO: Data fetching Promise declarations
|
||||
|
||||
const promiseResultMap = [
|
||||
|
|
@ -242,14 +282,81 @@ export default {
|
|||
resultKey: "signature",
|
||||
promise: signaturePromise,
|
||||
},
|
||||
{
|
||||
resultKey: "wipers",
|
||||
promise: wipersPromise,
|
||||
},
|
||||
{
|
||||
resultKey: "rainDefense",
|
||||
promise: rainDefensePromise,
|
||||
},
|
||||
{
|
||||
resultKey: "supportingItems",
|
||||
promise: supportingItemsPromise,
|
||||
},
|
||||
];
|
||||
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
|
||||
const glassParts = store.getters.order.lineItems.glassParts ?? [];
|
||||
|
||||
let availableLineItems = [
|
||||
resultMap.rainDefense,
|
||||
...resultMap.supportingItems,
|
||||
...resultMap.wipers,
|
||||
...glassParts,
|
||||
];
|
||||
|
||||
const lineItemsFromStore = store.getters.order.lineItems;
|
||||
|
||||
await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
||||
{
|
||||
availableLineItems: availableLineItems,
|
||||
},
|
||||
"payment",
|
||||
false
|
||||
);
|
||||
|
||||
// Promo logic
|
||||
const promoCodeFromQueryString = getQuerystringParameter(queryStrings.PROMO);
|
||||
|
||||
const { validatePromoResponse, revalidatePromoResponse } =
|
||||
await revalidatePromosAndValidateNewPromo(
|
||||
promoCodeFromQueryString,
|
||||
availableLineItems,
|
||||
"payment-method"
|
||||
);
|
||||
|
||||
availableLineItems.push(...(validatePromoResponse?.orderPromos ?? []));
|
||||
// End of promo logic
|
||||
|
||||
const taxedAvailableLineItems = 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,
|
||||
pricedAvailableLineItems: availableLineItems,
|
||||
},
|
||||
"payment-method",
|
||||
false
|
||||
);
|
||||
|
||||
// Match all available line items to the line items as they are in the store
|
||||
// and rebuild the original structure.
|
||||
const lineItems = mapTaxedLineItemsToStoreFormat(availableLineItems, lineItemsFromStore);
|
||||
|
||||
// Call the "next" function to complete the transition to this page.
|
||||
next(async (vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
vm.fetchSignatureInfo(resultMap.signature);
|
||||
|
||||
vm.availableLineItems = taxedAvailableLineItems;
|
||||
vm.lineItems = lineItems;
|
||||
});
|
||||
},
|
||||
computed: {
|
||||
|
|
@ -276,6 +383,9 @@ export default {
|
|||
switchPaymentText() {
|
||||
return this.getCmsContent("PaymentMethodWidget", "QuestionText");
|
||||
},
|
||||
damageInfo() {
|
||||
return this.$store.getters.damage;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
arePagePrerequisitesValid() {
|
||||
|
|
@ -312,7 +422,7 @@ export default {
|
|||
const scheduleReqs = !!(
|
||||
schedule.date &&
|
||||
schedule.startTime &&
|
||||
(!isMobile || schedule.endTime) &&
|
||||
schedule.endTime &&
|
||||
schedule.jobMaxMinutes &&
|
||||
schedule.jobMinMinutes
|
||||
);
|
||||
|
|
@ -466,6 +576,7 @@ export default {
|
|||
funnelHeader,
|
||||
navbar,
|
||||
loadingModal,
|
||||
cart,
|
||||
paymentSwitch,
|
||||
},
|
||||
};
|
||||
|
|
@ -474,7 +585,7 @@ export default {
|
|||
<style lang="scss">
|
||||
.hop-iframe {
|
||||
position: relative;
|
||||
min-height: 1120px;
|
||||
min-height: 650px;
|
||||
width: 100%;
|
||||
border: 0 none;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,4 +55,7 @@ export default {
|
|||
:deep(.review-block-content > ul) {
|
||||
margin-bottom: 0rem;
|
||||
}
|
||||
.review-block-content {
|
||||
width: 90%;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ export default {
|
|||
const scheduleReqs = !!(
|
||||
schedule.date &&
|
||||
schedule.startTime &&
|
||||
(!isMobile || schedule.endTime) &&
|
||||
schedule.endTime &&
|
||||
schedule.jobMaxMinutes &&
|
||||
schedule.jobMinMinutes
|
||||
);
|
||||
|
|
|
|||
|
|
@ -286,6 +286,7 @@ describe("service-location.vue", () => {
|
|||
const newServiceZipCodeQuestion = {
|
||||
zipCode: "61606",
|
||||
state: "IL",
|
||||
zipCodeCtu: "01526",
|
||||
};
|
||||
|
||||
const serviceZipCodeComponent = wrapper.findComponent({
|
||||
|
|
@ -316,6 +317,7 @@ describe("service-location.vue", () => {
|
|||
const newServiceZipCodeQuestion = {
|
||||
zipCode: "61606",
|
||||
state: "IL",
|
||||
zipCodeCtu: "01526",
|
||||
};
|
||||
|
||||
const mobileLocationQuestions = {
|
||||
|
|
@ -365,6 +367,7 @@ describe("service-location.vue", () => {
|
|||
const newServiceZipCodeQuestion = {
|
||||
zipCode: "61606",
|
||||
state: "IL",
|
||||
zipCodeCtu: "01526",
|
||||
};
|
||||
|
||||
wrapper.vm.selectedAppointmentType = "Inshop";
|
||||
|
|
@ -395,6 +398,7 @@ describe("service-location.vue", () => {
|
|||
const newServiceZipCodeQuestion = {
|
||||
zipCode: "45433",
|
||||
state: "OH",
|
||||
zipCodeCtu: "01526",
|
||||
};
|
||||
|
||||
// Act
|
||||
|
|
@ -511,11 +515,13 @@ describe("service-location.vue", () => {
|
|||
wrapper.vm.serviceZipCodeQuestion = {
|
||||
zipCode: "61606",
|
||||
state: "IL",
|
||||
zipCodeCtu: "01526",
|
||||
};
|
||||
|
||||
const newServiceZipCodeInfo = {
|
||||
state: "OH",
|
||||
zipCode: "43081",
|
||||
zipCodeCtu: "01526",
|
||||
};
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -245,6 +245,7 @@ export default {
|
|||
return {
|
||||
state: this.state,
|
||||
zipCode: this.zipCode,
|
||||
zipCodeCtu: this.zipCodeCtu,
|
||||
};
|
||||
},
|
||||
set: function (newValue) {
|
||||
|
|
@ -256,6 +257,7 @@ export default {
|
|||
|
||||
this.state = newValue.state;
|
||||
this.zipCode = newValue.zipCode;
|
||||
this.zipCodeCtu = newValue.zipCodeCtu;
|
||||
|
||||
this.$nextTick();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ describe("service-zip-modal-question.vue", () => {
|
|||
let serviceZipCodeQuestion = {
|
||||
state: "",
|
||||
zipCode: "",
|
||||
zipCodeCtu: "",
|
||||
};
|
||||
|
||||
// Arrange
|
||||
|
|
@ -135,6 +136,7 @@ describe("service-zip-modal-question.vue", () => {
|
|||
let serviceZipCodeQuestion = {
|
||||
state: "OH",
|
||||
zipCode: "43235",
|
||||
zipCodeCtu: "01820",
|
||||
};
|
||||
|
||||
const wrapper = mount(serviceZipModalQuestion, {
|
||||
|
|
@ -156,6 +158,7 @@ describe("service-zip-modal-question.vue", () => {
|
|||
let serviceZipCodeQuestion = {
|
||||
state: "IL",
|
||||
zipCode: "61606",
|
||||
zipCodeCtu: "01526",
|
||||
};
|
||||
|
||||
const zip = "43235";
|
||||
|
|
@ -176,7 +179,7 @@ describe("service-zip-modal-question.vue", () => {
|
|||
|
||||
await wrapper.vm.setZipCode();
|
||||
|
||||
let expectedEmit = [[{ state: "OH", zipCode: "43235" }]];
|
||||
let expectedEmit = [[{ state: "OH", zipCode: "43235", zipCodeCtu: "01820" }]];
|
||||
|
||||
// Assert
|
||||
expect(wrapper.emitted("update:modelValue")).toEqual(expectedEmit);
|
||||
|
|
@ -187,6 +190,7 @@ describe("service-zip-modal-question.vue", () => {
|
|||
let serviceZipCodeQuestion = {
|
||||
state: "IL",
|
||||
zipCode: "61606",
|
||||
zipCodeCtu: "01526",
|
||||
};
|
||||
|
||||
const zip = "";
|
||||
|
|
@ -214,6 +218,7 @@ describe("service-zip-modal-question.vue", () => {
|
|||
let serviceZipCodeQuestion = {
|
||||
state: "IL",
|
||||
zipCode: "61606",
|
||||
zipCodeCtu: "01526",
|
||||
};
|
||||
|
||||
const zip = "11111";
|
||||
|
|
@ -241,6 +246,7 @@ describe("service-zip-modal-question.vue", () => {
|
|||
let serviceZipCodeQuestion = {
|
||||
state: "IL",
|
||||
zipCode: "61606",
|
||||
zipCodeCtu: "01526",
|
||||
};
|
||||
|
||||
const zip = "";
|
||||
|
|
@ -269,6 +275,7 @@ describe("service-zip-modal-question.vue", () => {
|
|||
let serviceZipCodeQuestion = {
|
||||
state: "IL",
|
||||
zipCode: "61606",
|
||||
zipCodeCtu: "01526",
|
||||
};
|
||||
|
||||
const zip = "123";
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ export default {
|
|||
this.resetModalButtonStyle();
|
||||
} else {
|
||||
this.internalModel.state = zipCodeData.state;
|
||||
this.internalModel.zipCodeCtu = zipCodeData.zipCodeCtu;
|
||||
|
||||
// retrieve mobile fee part
|
||||
const serviceZipCode = this.internalModel.zipCode;
|
||||
|
|
|
|||
|
|
@ -2191,13 +2191,13 @@ export const actions = {
|
|||
serviceLocationCity,
|
||||
serviceLocationState,
|
||||
serviceLocationZipCode,
|
||||
pricedAvailableLineItems,
|
||||
pricedLineItems,
|
||||
},
|
||||
pageNameToLog,
|
||||
}
|
||||
) {
|
||||
const flattenedLineItemsWithChildParts =
|
||||
getFlattenedArrayOfLineItemsWithChildParts(pricedAvailableLineItems);
|
||||
getFlattenedArrayOfLineItemsWithChildParts(pricedLineItems);
|
||||
|
||||
const lineItemsWithOnlyPriceInfo = flattenedLineItemsWithChildParts.map((lineItem) => ({
|
||||
partNumber: lineItem.partNumber,
|
||||
|
|
@ -2246,12 +2246,9 @@ export const actions = {
|
|||
|
||||
context.commit(storeMutations.UPDATE_LINE_ITEMS_SERVER_DATA, response.data.serverData);
|
||||
|
||||
pricedAvailableLineItems = addTaxesToPricedLineItems(
|
||||
pricedAvailableLineItems,
|
||||
response.data.taxedLineItems
|
||||
);
|
||||
pricedLineItems = addTaxesToPricedLineItems(pricedLineItems, response.data.taxedLineItems);
|
||||
|
||||
return pricedAvailableLineItems;
|
||||
return pricedLineItems;
|
||||
},
|
||||
|
||||
// The <addableVaps> parameter is an array of ALL available front wipers and rain defense
|
||||
|
|
@ -2621,7 +2618,7 @@ function addTaxesToPricedLineItems(pricedLineItems, taxingLineItems = []) {
|
|||
return pricedLineItems;
|
||||
}
|
||||
|
||||
export function mapTaxedAvailableLineItemsToStoreFormat(availableLineItems, storeLineItems) {
|
||||
export function mapTaxedLineItemsToStoreFormat(availableLineItems, storeLineItems) {
|
||||
// clone the lineItems array because what we're passing in is referencing the store directly
|
||||
const lineItems = deepClone(storeLineItems);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue