diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index 7994d601c..99f961425 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -80,7 +80,9 @@ async function getLatestPageForRedirection() { fmgPageValues.CAPABILITY_QUESTIONS ); - const isVinOptionalVehicle = await store.dispatch(storeActions.IS_VIN_OPTIONAL_VEHICLE); + const isVinOptionalVehicle = store.getters.order.vehicle.make + ? await store.dispatch(storeActions.IS_VIN_OPTIONAL_VEHICLE) + : false; if (!vehicleMakeComponent.methods.arePagePrerequisitesValid()) { return fmgPageValues.VEHICLE_YEAR; diff --git a/src/layouts/estimate/estimate.vue b/src/layouts/estimate/estimate.vue index d69c916c7..4aa5db241 100644 --- a/src/layouts/estimate/estimate.vue +++ b/src/layouts/estimate/estimate.vue @@ -23,7 +23,7 @@
@@ -258,6 +258,11 @@ export default { skipVinLookup() { return this.isRepair || this.isVinOptionalVehicle; }, + alertInfo() { + return this.isVinOptionalVehicle && !this.isRepair + ? "AlertQuoteVinOptional" + : "AlertQuoteReady"; + }, }, watch: { serviceZipCode() { diff --git a/src/layouts/quote/service-package-question/service-package-question.spec.js b/src/layouts/quote/service-package-question/service-package-question.spec.js index bd24ac752..e0608e713 100644 --- a/src/layouts/quote/service-package-question/service-package-question.spec.js +++ b/src/layouts/quote/service-package-question/service-package-question.spec.js @@ -6,6 +6,7 @@ import { mockProcessedCmsContent, inputQuestionWidgetAnswers, } from "./service-package-question-test-helper"; +import { nextTick } from "vue"; jest.mock("@/store", () => ({ commit: jest.fn(), @@ -49,11 +50,12 @@ describe("service-package-question.vue", () => { const packageNameKey = "05_01_CSR_Quote_Standard_Repair"; Object.assign(processedCmsContent, mockProcessedCmsContent[packageNameKey]); }); - it("should emit relevant VAPS items in an array", () => { + it("should emit relevant VAPS items in an array", async () => { // Arrange const wrapper = setupMocks({}); // Act - wrapper.componentVM.selectedValues = "TierThree"; + wrapper.componentVM.selectedPackageName = "TierThree"; + await nextTick(); // Assert expect(wrapper.emitted()["update:modelValue"][0][0]).toEqual([ diff --git a/src/layouts/quote/service-package-question/service-package-question.vue b/src/layouts/quote/service-package-question/service-package-question.vue index b096c34c0..15b0db7d5 100644 --- a/src/layouts/quote/service-package-question/service-package-question.vue +++ b/src/layouts/quote/service-package-question/service-package-question.vue @@ -4,7 +4,7 @@ :groupName="groupName" buttonTypeString="servicePackageRadio" :buttonTypeObject="servicePackageRadio" - v-model="selectedValues" + v-model="selectedPackageName" isRequired /> @@ -35,19 +35,21 @@ export default { data() { return { servicePackageRadio: servicePackageRadio, + selectedPackageName: null, }; }, - computed: { - selectedValues: { - get: function () { - return this.modelValue; - }, - set: function (newValue) { - const VapsProductsInSelectedPackage = - this.getVapsLineItemsForSelectedPackage(newValue); - this.$emit("update:modelValue", VapsProductsInSelectedPackage); - }, + watch: { + availableLineItems() { + if (this.$store.getters.lineItems.supportingItems) { + this.selectDefaultPackage(); + } }, + selectedPackageName(newValue) { + const VapsProductsInSelectedPackage = this.getVapsLineItemsForSelectedPackage(newValue); + this.$emit("update:modelValue", VapsProductsInSelectedPackage); + }, + }, + computed: { nullSafeAvailableLineItems() { return this.availableLineItems ?? []; }, @@ -208,6 +210,50 @@ export default { }); return vapsPrice; }, + selectDefaultPackage() { + const vapsFromStore = this.$store.getters.lineItems.vaps; + let lowestTierForPackage = packageNames.TIER_ONE; + vapsFromStore.every((vapsItem) => { + let lowestTierForThisItem = this.getLowestTierForThisItem(vapsItem); + if (lowestTierForThisItem === packageNames.TIER_THREE) { + lowestTierForPackage = packageNames.TIER_THREE; + return false; + } else if (lowestTierForThisItem === packageNames.TIER_TWO) { + lowestTierForPackage = packageNames.TIER_TWO; + return true; + } else { + return true; + } + }); + this.selectedPackageName = lowestTierForPackage; + }, + getLowestTierForThisItem(vapsItem) { + let lowestTierForThisItem = null; + switch (vapsItem.partType) { + case partTypeStrings.FRONT_WIPER: + if (this.frontWipersApplicableForTierThree) { + lowestTierForThisItem = packageNames.TIER_THREE; + } + if (this.frontWipersApplicableForTierTwo) { + lowestTierForThisItem = packageNames.TIER_TWO; + } + break; + case partTypeStrings.REAR_WIPER: + if (this.rearWiperApplicableForTierThree) { + lowestTierForThisItem = packageNames.TIER_THREE; + } + if (this.rearWiperApplicableForTierTwo) { + lowestTierForThisItem = packageNames.TIER_TWO; + } + break; + case partTypeStrings.RAIN_DEFENSE: + if (this.rainDefenseApplicableForTierThree) { + lowestTierForThisItem = packageNames.TIER_THREE; + } + break; + } + return lowestTierForThisItem; + }, getVapsLineItemsForSelectedPackage(packageName) { const vapsLineItemsForSelectedPackage = []; if (packageName === packageNames.TIER_TWO) { diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index b960a7996..1fbe50c28 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -10,11 +10,7 @@
-