CSR-1384: use deepClone on resultMap and glassParts
This commit is contained in:
parent
5a3d9c3b80
commit
ab1f47d038
1 changed files with 21 additions and 17 deletions
|
|
@ -105,6 +105,7 @@ import alert from "@/ux-components/alert/alert";
|
|||
|
||||
import baseMixin from "@/mixins/base-mixin.js";
|
||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||
import { deepClone } from "@/helpers/object-helper";
|
||||
import { storeActions } from "@/constants/store-actions";
|
||||
import store from "@/store";
|
||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||
|
|
@ -120,6 +121,7 @@ export default {
|
|||
null,
|
||||
"payment-method"
|
||||
);
|
||||
|
||||
const rainDefensePromise = baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
storeActions.GET_RAIN_DEFENSE,
|
||||
null,
|
||||
|
|
@ -151,28 +153,30 @@ export default {
|
|||
];
|
||||
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
const clonedGlassParts = store.getters.order.lineItems.glassParts
|
||||
? JSON.parse(JSON.stringify(store.getters.order.lineItems.glassParts))
|
||||
: [];
|
||||
|
||||
const resultMapCopy = deepClone(resultMap) ?? [];
|
||||
|
||||
const glassPartsCopy = deepClone(store.getters.order.lineItems.glassParts) ?? [];
|
||||
|
||||
const availableLineItems = [
|
||||
resultMap.rainDefense,
|
||||
...resultMap.supportingItems,
|
||||
...resultMap.wipers,
|
||||
...clonedGlassParts,
|
||||
resultMapCopy.rainDefense,
|
||||
...resultMapCopy.supportingItems,
|
||||
...resultMapCopy.wipers,
|
||||
...glassPartsCopy,
|
||||
];
|
||||
|
||||
// TODO - DO WE NEED TO GET PRICINGRESULTS HERE? SEEMS TO BE THE SAME AS availableLineItems
|
||||
const pricingResults = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
||||
{
|
||||
availableLineItems: availableLineItems,
|
||||
},
|
||||
"payment-method",
|
||||
false
|
||||
);
|
||||
// const pricingResults = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||
// storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
||||
// {
|
||||
// availableLineItems: availableLineItems,
|
||||
// },
|
||||
// "payment-method",
|
||||
// false
|
||||
// );
|
||||
const lineItems = store.getters.lineItems;
|
||||
|
||||
const cartItems = [...clonedGlassParts, ...lineItems.supportingItems, ...lineItems.vaps];
|
||||
const cartItems = [...glassPartsCopy, ...lineItems.supportingItems, ...lineItems.vaps];
|
||||
|
||||
// Call the "next" function to complete the transition to this page.
|
||||
next((vm) => {
|
||||
|
|
@ -181,7 +185,7 @@ export default {
|
|||
vm.cartItems = cartItems; // TOBEREMOVED BY AJC IN CSR-1384
|
||||
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
vm.availableLineItems = pricingResults;
|
||||
vm.availableLineItems = availableLineItems;
|
||||
vm.lineItems = lineItems;
|
||||
});
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue