Merge pull request #1501 from Safelite/feature/CSR-1391.1
Feature/csr 1391.1
This commit is contained in:
commit
8e49fa5713
1 changed files with 115 additions and 1 deletions
|
|
@ -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 { mapTaxedAvailableLineItemsToStoreFormat } 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,84 @@ 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 = mapTaxedAvailableLineItemsToStoreFormat(
|
||||
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 +386,9 @@ export default {
|
|||
switchPaymentText() {
|
||||
return this.getCmsContent("PaymentMethodWidget", "QuestionText");
|
||||
},
|
||||
damageInfo() {
|
||||
return this.$store.getters.damage;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
arePagePrerequisitesValid() {
|
||||
|
|
@ -466,6 +579,7 @@ export default {
|
|||
funnelHeader,
|
||||
navbar,
|
||||
loadingModal,
|
||||
cart,
|
||||
paymentSwitch,
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue