From 7e23c40602ef28db42a3341acf3ed233e070628b Mon Sep 17 00:00:00 2001 From: Katie Kroell Date: Thu, 8 Jun 2023 16:10:47 -0400 Subject: [PATCH] autoselect if only one vehicle on policy --- src/layouts/policy-vehicles/policy-vehicles.vue | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/layouts/policy-vehicles/policy-vehicles.vue b/src/layouts/policy-vehicles/policy-vehicles.vue index 82ab834f..f38516f6 100644 --- a/src/layouts/policy-vehicles/policy-vehicles.vue +++ b/src/layouts/policy-vehicles/policy-vehicles.vue @@ -56,8 +56,7 @@ export default { } }, mounted() { - // clear previously selected vehicle so that the blurred vehicle image displays on page entry - useMainStore().resetVehicleState(); + this.autoSelectIfOneVehicle(); }, async beforeRouteEnter(to, from, next) { @@ -127,8 +126,12 @@ export default { }, }; } - }, - + }, + autoSelectIfOneVehicle() { + if (this.VehiclesFromApi.length == 1) { + this.selectedVehicleVin = this.VehiclesFromApi[0].vin; + } + } }, computed:{ VehiclesForQuestions() { @@ -165,7 +168,7 @@ export default { } else { - // get vehicle details from selected vin + // get vehicle details from selected VIN const vehicle = await this.lookupVehicleByVin(value); // handle error in case vehicle info doesn't come back for selected VIN @@ -177,7 +180,8 @@ export default { // save selected vehicle to the store this.mainStore.updateVehicle(vehicle.data); this.displayGeneric = true; - + + // get the style(s) associated with the selected YMM const styleOptions = await this.mainStore.getVehicleStyles( vehicle.data.year, vehicle.data.make,