CSR-1384: updates for cart work, using lineItems instead of cartItems
This commit is contained in:
parent
f8f22fb619
commit
348dba428a
2 changed files with 39 additions and 43 deletions
|
|
@ -54,47 +54,34 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import cart from "@/fmg-components/cart/cart";
|
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header";
|
|
||||||
import { packageNames } from "@/constants/package-names";
|
|
||||||
import {
|
import {
|
||||||
getHighestFullySatisfiedTier,
|
getHighestFullySatisfiedTier,
|
||||||
containsLineItemWithPartType,
|
containsLineItemWithPartType,
|
||||||
getPackageContents,
|
getPackageContents,
|
||||||
findLineItemsWithPartType,
|
findLineItemsWithPartType,
|
||||||
} from "@/helpers/service-package-helper";
|
} from "@/helpers/service-package-helper";
|
||||||
import reviewBlock from "@/layouts/review/review-block/review-block";
|
|
||||||
import textLink from "@/ux-components/text-link/text-link";
|
import textLink from "@/ux-components/text-link/text-link";
|
||||||
import textBlock from "@/digital-components/text-block/text-block";
|
import textBlock from "@/digital-components/text-block/text-block";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "modal",
|
name: "modal",
|
||||||
props: {
|
props: {
|
||||||
headerCmsWidgetName: String,
|
|
||||||
servicePackageOptionsCmsName: String,
|
|
||||||
damage: Object,
|
damage: Object,
|
||||||
storeLineItems: Object,
|
servicePackageOptionsCmsName: String,
|
||||||
availableLineItems: Object,
|
availableLineItems: Object,
|
||||||
allowableCartItems: Object,
|
lineItems: Object,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isActive: false,
|
isActive: false,
|
||||||
//availableVaps: [], TO DO Do we need this?
|
|
||||||
packageWithVAPS: false,
|
packageWithVAPS: false,
|
||||||
// packageLevel: "",
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
toggleClass: function (event) {
|
toggleClass: function (event) {
|
||||||
this.isActive = !this.isActive;
|
this.isActive = !this.isActive;
|
||||||
},
|
},
|
||||||
initializeComponent(apiResponses) {
|
|
||||||
//TO DO Do we need this?
|
|
||||||
// const vapsFromApi = [...apiResponses.wipers, apiResponses.rainDefense];
|
|
||||||
// this.availableVaps = vapsFromApi;
|
|
||||||
},
|
|
||||||
getPackagePriceString(packageName) {
|
getPackagePriceString(packageName) {
|
||||||
const formattedPriceFloat = parseFloat(this.getPackagePrice(packageName)).toFixed(2);
|
const formattedPriceFloat = parseFloat(this.getPackagePrice(packageName)).toFixed(2);
|
||||||
return (this.isInsuranceSelected ? "As little as $" : "$") + formattedPriceFloat;
|
return (this.isInsuranceSelected ? "As little as $" : "$") + formattedPriceFloat;
|
||||||
|
|
@ -103,7 +90,7 @@ export default {
|
||||||
let priceFloat = this.isInsuranceSelected
|
let priceFloat = this.isInsuranceSelected
|
||||||
? 0
|
? 0
|
||||||
: baseMixin.methods.getTierOnePackagePrice(
|
: baseMixin.methods.getTierOnePackagePrice(
|
||||||
baseMixin.methods.filterOutFees(this.nullSafeAvailableLineItems)
|
baseMixin.methods.filterOutFees(this.availableLineItems)
|
||||||
);
|
);
|
||||||
|
|
||||||
priceFloat += this.getVapsPrice(packageName);
|
priceFloat += this.getVapsPrice(packageName);
|
||||||
|
|
@ -127,7 +114,7 @@ export default {
|
||||||
getVapsLineItemsForSelectedPackage(packageName) {
|
getVapsLineItemsForSelectedPackage(packageName) {
|
||||||
const packageContentTypes = getPackageContents(
|
const packageContentTypes = getPackageContents(
|
||||||
this.glassToReplace,
|
this.glassToReplace,
|
||||||
this.nullSafeAvailableLineItems,
|
this.availableLineItems,
|
||||||
this.isRepair,
|
this.isRepair,
|
||||||
packageName
|
packageName
|
||||||
);
|
);
|
||||||
|
|
@ -136,10 +123,9 @@ export default {
|
||||||
|
|
||||||
packageContentTypes.forEach((vapType) => {
|
packageContentTypes.forEach((vapType) => {
|
||||||
vapsLineItemsForSelectedPackage.push(
|
vapsLineItemsForSelectedPackage.push(
|
||||||
...findLineItemsWithPartType(vapType, this.nullSafeAvailableLineItems)
|
...findLineItemsWithPartType(vapType, this.availableLineItems)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
// console.log("VapsLineItems:", vapsLineItemsForSelectedPackage);
|
|
||||||
return vapsLineItemsForSelectedPackage;
|
return vapsLineItemsForSelectedPackage;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -180,7 +166,7 @@ export default {
|
||||||
displayedPackageLineItems() {
|
displayedPackageLineItems() {
|
||||||
const displayedPackageLineItems = [];
|
const displayedPackageLineItems = [];
|
||||||
const packageLineItems = this.getVapsLineItemsForSelectedPackage(this.packageLevel);
|
const packageLineItems = this.getVapsLineItemsForSelectedPackage(this.packageLevel);
|
||||||
//TO DO Could we get the same list from this.storeLineItems?
|
// TODO Determine if we could get the same list from this.lineItems?
|
||||||
packageLineItems?.forEach((item) => {
|
packageLineItems?.forEach((item) => {
|
||||||
let price = item.sellingPrice + item.kitPrice + item.laborAmount;
|
let price = item.sellingPrice + item.kitPrice + item.laborAmount;
|
||||||
const packageLineItem = {
|
const packageLineItem = {
|
||||||
|
|
@ -191,7 +177,6 @@ export default {
|
||||||
};
|
};
|
||||||
displayedPackageLineItems.push(packageLineItem);
|
displayedPackageLineItems.push(packageLineItem);
|
||||||
});
|
});
|
||||||
// console.log("What displayedPackageLineItems is", packageLineItems);
|
|
||||||
return displayedPackageLineItems;
|
return displayedPackageLineItems;
|
||||||
},
|
},
|
||||||
displayedNonPackageLineItems() {
|
displayedNonPackageLineItems() {
|
||||||
|
|
@ -236,11 +221,11 @@ export default {
|
||||||
return this.damage.isRepair;
|
return this.damage.isRepair;
|
||||||
},
|
},
|
||||||
vaps() {
|
vaps() {
|
||||||
const vaps = this.storeLineItems?.vaps;
|
const vaps = this.lineItems?.vaps;
|
||||||
return vaps?.length > 0 ? vaps : [];
|
return vaps?.length > 0 ? vaps : [];
|
||||||
},
|
},
|
||||||
supportingItems() {
|
supportingItems() {
|
||||||
const supportingItems = this.storeLineItems?.supportingItems;
|
const supportingItems = this.lineItems?.supportingItems;
|
||||||
return supportingItems?.length > 0 ? supportingItems : [];
|
return supportingItems?.length > 0 ? supportingItems : [];
|
||||||
},
|
},
|
||||||
recycleLabel() {
|
recycleLabel() {
|
||||||
|
|
@ -258,9 +243,6 @@ export default {
|
||||||
// }
|
// }
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
nullSafeAvailableLineItems() {
|
|
||||||
return this.availableLineItems ?? [];
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
textBlock,
|
textBlock,
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
<cart
|
<cart
|
||||||
:damage="damageInfo"
|
:damage="damageInfo"
|
||||||
:storeLineItems="storeLineItems"
|
:availableLineItems="availableLineItems || []"
|
||||||
:availableLineItems="cartItems"
|
:lineItems="lineItems"
|
||||||
servicePackageOptionsCmsName="ServicePackageTitle"
|
servicePackageOptionsCmsName="ServicePackageTitle"
|
||||||
@cart-remove="cartRemove" />
|
@cart-remove="cartRemove" />
|
||||||
|
|
||||||
|
|
@ -34,9 +34,10 @@
|
||||||
|
|
||||||
<add-vaps-modal-buttons
|
<add-vaps-modal-buttons
|
||||||
:cartItems="cartItems"
|
:cartItems="cartItems"
|
||||||
:wiperItems="availableWipers"
|
:wiperItems="availableWipers || []"
|
||||||
:rainDefenseItem="availableRainDefense"
|
:rainDefenseItem="availableRainDefense || {}"
|
||||||
vapsTilesCmsName="VapsProductTiles" />
|
vapsTilesCmsName="VapsProductTiles"
|
||||||
|
v-on="{ 'buttonEvent.openModal': openModalAction }" />
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<button v-on:click="ccdPayment">
|
<button v-on:click="ccdPayment">
|
||||||
|
|
@ -76,6 +77,8 @@
|
||||||
alt="Afterpay" />
|
alt="Afterpay" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<button @click="openModalAction('RainDefenseModal')">OPEN MODAL</button>
|
||||||
|
<contentGroupModal ref="RainDefenseModal" cmsWidgetName="RainDefenseModal" />
|
||||||
<navbar
|
<navbar
|
||||||
cmsWidgetName="FunnelFooterWidget"
|
cmsWidgetName="FunnelFooterWidget"
|
||||||
:isForwardActionDisabled="!meta.valid"
|
:isForwardActionDisabled="!meta.valid"
|
||||||
|
|
@ -96,6 +99,7 @@ import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-heade
|
||||||
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 cart from "@/fmg-components/cart/cart";
|
||||||
import addVapsModalButtons from "@/fmg-components/add-vaps-modal-buttons/add-vaps-modal-buttons";
|
import addVapsModalButtons from "@/fmg-components/add-vaps-modal-buttons/add-vaps-modal-buttons";
|
||||||
|
import contentGroupModal from "@/fmg-components/content-group-modal/content-group-modal";
|
||||||
import { submitWorkOrder } from "@/helpers/heritage-integration/order-helper.js";
|
import { submitWorkOrder } from "@/helpers/heritage-integration/order-helper.js";
|
||||||
import alert from "@/ux-components/alert/alert";
|
import alert from "@/ux-components/alert/alert";
|
||||||
|
|
||||||
|
|
@ -156,6 +160,8 @@ export default {
|
||||||
...resultMap.wipers,
|
...resultMap.wipers,
|
||||||
...clonedGlassParts,
|
...clonedGlassParts,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// TODO - DO WE NEED TO GET PRICINGRESULTS HERE? SEEMS TO BE THE SAME AS availableLineItems
|
||||||
const pricingResults = await baseMixin.methods.dispatchStoreActionWithLogging(
|
const pricingResults = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
||||||
{
|
{
|
||||||
|
|
@ -164,30 +170,33 @@ export default {
|
||||||
"payment-method",
|
"payment-method",
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
const storeLineItems = store.getters.lineItems;
|
const lineItems = store.getters.lineItems;
|
||||||
|
|
||||||
const cartItems = [
|
const cartItems = [
|
||||||
...clonedGlassParts,
|
...clonedGlassParts,
|
||||||
...storeLineItems.supportingItems,
|
...lineItems.supportingItems,
|
||||||
...storeLineItems.vaps,
|
...lineItems.vaps,
|
||||||
];
|
];
|
||||||
|
|
||||||
// Call the "next" function to complete the transition to this page.
|
// Call the "next" function to complete the transition to this page.
|
||||||
next((vm) => {
|
next((vm) => {
|
||||||
|
vm.availableWipers = resultMap.wipers; // TOBEREMOVED BY AJC IN CSR-1384
|
||||||
|
vm.availableRainDefense = resultMap.rainDefense; // TOBEREMOVED BY AJC IN CSR-1384
|
||||||
|
vm.cartItems = cartItems; // TOBEREMOVED BY AJC IN CSR-1384
|
||||||
|
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
vm.availableLineItems = pricingResults;
|
vm.availableLineItems = pricingResults;
|
||||||
vm.availableWipers = resultMap.wipers;
|
vm.lineItems = lineItems;
|
||||||
vm.availableRainDefense = resultMap.rainDefense;
|
|
||||||
vm.cartItems = cartItems;
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
cartItems: [],
|
cartItems: [], // TOBEREMOVED BY AJC IN CSR-1384
|
||||||
availableWipers: null,
|
availableWipers: null, // TOBEREMOVED BY AJC IN CSR-1384
|
||||||
availableRainDefense: null,
|
availableRainDefense: null, // TOBEREMOVED BY AJC IN CSR-1384
|
||||||
|
|
||||||
|
lineItems: null,
|
||||||
availableLineItems: null,
|
availableLineItems: null,
|
||||||
supportingItems: null,
|
|
||||||
pricedGlassParts: null,
|
|
||||||
displayPaypalAlert: this.getPaypalAlert(),
|
displayPaypalAlert: this.getPaypalAlert(),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
@ -195,6 +204,9 @@ export default {
|
||||||
arePagePrerequisitesValid() {
|
arePagePrerequisitesValid() {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
openModalAction(modalName) {
|
||||||
|
this.$refs[modalName].openModal();
|
||||||
|
},
|
||||||
getPaypalAlert() {
|
getPaypalAlert() {
|
||||||
return store.getters.order.payment.piaErrorCode ? true : false;
|
return store.getters.order.payment.piaErrorCode ? true : false;
|
||||||
},
|
},
|
||||||
|
|
@ -209,7 +221,7 @@ export default {
|
||||||
const matchedIndices = [];
|
const matchedIndices = [];
|
||||||
this.cartItems.forEach((cartItem, i) => {
|
this.cartItems.forEach((cartItem, i) => {
|
||||||
if (cartItem.partType === item.partType) {
|
if (cartItem.partType === item.partType) {
|
||||||
console.log("adding this to matchedIndices: ", i);
|
// console.log("adding this to matchedIndices: ", i);
|
||||||
matchedIndices.push(i);
|
matchedIndices.push(i);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -265,6 +277,7 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
damageInfo() {
|
damageInfo() {
|
||||||
|
// console.log("this.$store.getters.damage ", this.$store.getters.damage)
|
||||||
return this.$store.getters.damage;
|
return this.$store.getters.damage;
|
||||||
},
|
},
|
||||||
storeLineItems() {
|
storeLineItems() {
|
||||||
|
|
@ -281,6 +294,7 @@ export default {
|
||||||
cart,
|
cart,
|
||||||
alert,
|
alert,
|
||||||
addVapsModalButtons,
|
addVapsModalButtons,
|
||||||
|
contentGroupModal,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue