autoselect if only one vehicle on policy

This commit is contained in:
Katie Kroell 2023-06-08 16:10:47 -04:00
parent fa4233f2d2
commit 7e23c40602

View file

@ -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,