From 0b4d626d90814af3b262b9d0da9c99ab73819d94 Mon Sep 17 00:00:00 2001 From: brydon1 Date: Wed, 21 Jun 2023 17:14:33 -0400 Subject: [PATCH] Minor adjustments --- .../policy-vehicles/policy-vehicles.vue | 35 ++++++++++--------- src/store/index.js | 8 ++--- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/layouts/policy-vehicles/policy-vehicles.vue b/src/layouts/policy-vehicles/policy-vehicles.vue index 48d585ea..c0aa9e33 100644 --- a/src/layouts/policy-vehicles/policy-vehicles.vue +++ b/src/layouts/policy-vehicles/policy-vehicles.vue @@ -50,9 +50,11 @@ export default { name: "policy-vehicles", mixins: [BaseFormMixin], data() { - return { - selectedVehicleVin: "", - bailout: false + const policyVehicles = useMainStore().pageData(issPageValues.POLICY_VEHICLES); + return { + policyVehicles: policyVehicles, + selectedVehicleVin: policyVehicles.length == 0 ? "" : policyVehicles[0].vin, + bailout: false } }, async beforeRouteEnter(to, from, next) @@ -64,13 +66,14 @@ export default { { resultKey: "cmsContent", promise: cmsContentPromise, - },]; - //use resultMap to populate layout content. - let resultMap = await settleAllPromises(promiseResultMap); - next((vm) => { - vm.setCmsContent(resultMap.cmsContent); - }); - }, + }, + ]; + //use resultMap to populate layout content. + let resultMap = await settleAllPromises(promiseResultMap); + next((vm) => { + vm.setCmsContent(resultMap.cmsContent); + }); + }, methods: { backButtonAction() { @@ -95,6 +98,7 @@ export default { // If they go backwards select vehicle => forward => one deductible => back to vehicle selection => forward again => right info // backwards => vehicle unverified => clear coverage info // keep this in mind + console.log("Going to update vehicle"); this.mainStore.updateVehicle(this.vehicleFromLookup); } return this.navigateForward(); @@ -139,7 +143,7 @@ export default { computed:{ VehiclesForQuestions() { // Map API result data, to address-vehicles data structure - const vehicles = this.VehiclesFromApi; + const vehicles = this.policyVehicles; const mappedData = vehicles.map((v) => { const maskSymbol = "X"; const vinStart = maskSymbol.repeat(v.vin.length - 6); @@ -154,21 +158,18 @@ export default { }); return mappedData; }, - VehiclesFromApi() { - return useMainStore().pageData(issPageValues.POLICY_VEHICLES); - }, noCoverageForSelectedVehicle() { - const vehicle = this.VehiclesFromApi.find((vehicle) => { return vehicle.vin == this.selectedVehicleVin; }); + const vehicle = this.policyVehicles.find((vehicle) => { return vehicle.vin == this.selectedVehicleVin; }); return vehicle.coverages.length == 0; }, deductibleForSelectedVehicle() { - const vehicle = this.VehiclesFromApi.find((vehicle) => { return vehicle.vin == this.selectedVehicleVin; }); + const vehicle = this.policyVehicles.find((vehicle) => { return vehicle.vin == this.selectedVehicleVin; }); return vehicle?.coverages?.length == 0 ?? true ? 0 : vehicle.coverages[0].deductible; }, repairWaivedForSelectedVehicle() { - const vehicle = this.VehiclesFromApi.find((vehicle) => { return vehicle.vin == this.selectedVehicleVin; }); + const vehicle = this.policyVehicles.find((vehicle) => { return vehicle.vin == this.selectedVehicleVin; }); return vehicle.endorsements?.includes(endorsementOptions.REPAIR_WAIVED) ?? false; } }, diff --git a/src/store/index.js b/src/store/index.js index e0e18fdd..9beed8c2 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -52,7 +52,6 @@ const getDefaultState = () => { isDamageGlassOnly: null, noCoverage: null, deductible: { - // if repair waived, then 0, otherwise same as other repair: null, // numerical value; how much customer owes on deductible in repair case replace: null // numerical value; how much customer owes on deductible in replace case, }, @@ -750,11 +749,9 @@ export const useMainStore = defineStore({ this.order.lineItems.vaps = partsData; }, - // TODO Where all will this be called and could it be an issue? updateVehicle(vehicle) { // Assuming that the method caller pass all the properties. // otherwise need to check for undefined for every property. - this.order.vehicle.carId = vehicle.carId; this.order.vehicle.category = vehicle.category; this.order.vehicle.year = vehicle.year; @@ -766,11 +763,10 @@ export const useMainStore = defineStore({ this.order.vehicle.imageVifNumber = vehicle.imageVifNumber; this.order.vehicle.imageColor = vehicle.imageVifColor; + // These could be undefined this.order.policy.noCoverage = vehicle.noCoverage; this.order.policy.deductible.replace = vehicle.deductible; - this.order.policy.deductible.repair = vehicle?.repairWaived ?? false - ? 0 - : vehicle.deductible; + this.order.policy.deductible.repair = vehicle?.repairWaived ?? false ? 0 : vehicle.deductible; this.resetSupportingItemsState(); this.resetVapsState();