CSR-1391 add cart to payment page
This commit is contained in:
parent
613518a4ef
commit
68c89b97d8
1 changed files with 115 additions and 1 deletions
|
|
@ -21,6 +21,19 @@
|
||||||
scrolling="no">
|
scrolling="no">
|
||||||
</iframe>
|
</iframe>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<cart
|
||||||
|
:damage="damageInfo"
|
||||||
|
:availableLineItems="availableLineItems"
|
||||||
|
:allowItemRemoval="false"
|
||||||
|
v-model="lineItems"
|
||||||
|
servicePackageOptionsCmsName="ServicePackageTitle"
|
||||||
|
recyclingModalCmsWidgetName="RecycleModal" />
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
<paymentSwitch
|
<paymentSwitch
|
||||||
cmsWidgetName="PaymentMethodWidget"
|
cmsWidgetName="PaymentMethodWidget"
|
||||||
:paymentType="paymentType"
|
:paymentType="paymentType"
|
||||||
|
|
@ -163,7 +176,7 @@
|
||||||
import funnelHeader from "@/fmg-components/funnel-header/funnel-header";
|
import funnelHeader from "@/fmg-components/funnel-header/funnel-header";
|
||||||
import navbar from "@/fmg-components/nav-bar/nav-bar";
|
import navbar from "@/fmg-components/nav-bar/nav-bar";
|
||||||
import loadingModal from "@/fmg-components/loading-modal/loading-modal.vue";
|
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 paymentSwitch from "./payment-switch/payment-switch.vue";
|
||||||
|
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
|
|
@ -175,6 +188,13 @@ import { applicationConfig } from "@/constants/application-config";
|
||||||
import { paymentMethods } from "@/constants/payment-method-constants";
|
import { paymentMethods } from "@/constants/payment-method-constants";
|
||||||
import { AppointmentTypeStrings } from "@/constants/schedule-constants";
|
import { AppointmentTypeStrings } from "@/constants/schedule-constants";
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
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";
|
import iframeResize from "../../../node_modules/iframe-resizer/js/iframeResizer.js";
|
||||||
|
|
||||||
|
|
@ -207,6 +227,8 @@ export default {
|
||||||
displayAmount: this.getDisplayAmountDue(),
|
displayAmount: this.getDisplayAmountDue(),
|
||||||
piaLineItems: this.getPiaLineItems(),
|
piaLineItems: this.getPiaLineItems(),
|
||||||
paypalPayment: this.isPaypal(),
|
paypalPayment: this.isPaypal(),
|
||||||
|
lineItems: [],
|
||||||
|
availableLineItems: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
directives: {
|
directives: {
|
||||||
|
|
@ -231,6 +253,24 @@ export default {
|
||||||
"payment"
|
"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
|
// TODO: Data fetching Promise declarations
|
||||||
|
|
||||||
const promiseResultMap = [
|
const promiseResultMap = [
|
||||||
|
|
@ -242,14 +282,84 @@ export default {
|
||||||
resultKey: "signature",
|
resultKey: "signature",
|
||||||
promise: signaturePromise,
|
promise: signaturePromise,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
resultKey: "wipers",
|
||||||
|
promise: wipersPromise,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
resultKey: "rainDefense",
|
||||||
|
promise: rainDefensePromise,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
resultKey: "supportingItems",
|
||||||
|
promise: supportingItemsPromise,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const resultMap = await settleAllPromises(promiseResultMap);
|
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.
|
// Call the "next" function to complete the transition to this page.
|
||||||
next(async (vm) => {
|
next(async (vm) => {
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
vm.fetchSignatureInfo(resultMap.signature);
|
vm.fetchSignatureInfo(resultMap.signature);
|
||||||
|
|
||||||
|
vm.availableLineItems = taxedAvailableLineItems;
|
||||||
|
vm.lineItems = lineItems;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -276,6 +386,9 @@ export default {
|
||||||
switchPaymentText() {
|
switchPaymentText() {
|
||||||
return this.getCmsContent("PaymentMethodWidget", "QuestionText");
|
return this.getCmsContent("PaymentMethodWidget", "QuestionText");
|
||||||
},
|
},
|
||||||
|
damageInfo() {
|
||||||
|
return this.$store.getters.damage;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
arePagePrerequisitesValid() {
|
arePagePrerequisitesValid() {
|
||||||
|
|
@ -466,6 +579,7 @@ export default {
|
||||||
funnelHeader,
|
funnelHeader,
|
||||||
navbar,
|
navbar,
|
||||||
loadingModal,
|
loadingModal,
|
||||||
|
cart,
|
||||||
paymentSwitch,
|
paymentSwitch,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue