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() { mounted() {
// clear previously selected vehicle so that the blurred vehicle image displays on page entry this.autoSelectIfOneVehicle();
useMainStore().resetVehicleState();
}, },
async beforeRouteEnter(to, from, next) async beforeRouteEnter(to, from, next)
{ {
@ -128,7 +127,11 @@ export default {
}; };
} }
}, },
autoSelectIfOneVehicle() {
if (this.VehiclesFromApi.length == 1) {
this.selectedVehicleVin = this.VehiclesFromApi[0].vin;
}
}
}, },
computed:{ computed:{
VehiclesForQuestions() { VehiclesForQuestions() {
@ -165,7 +168,7 @@ export default {
} }
else { else {
// get vehicle details from selected vin // get vehicle details from selected VIN
const vehicle = await this.lookupVehicleByVin(value); const vehicle = await this.lookupVehicleByVin(value);
// handle error in case vehicle info doesn't come back for selected VIN // handle error in case vehicle info doesn't come back for selected VIN
@ -178,6 +181,7 @@ export default {
this.mainStore.updateVehicle(vehicle.data); this.mainStore.updateVehicle(vehicle.data);
this.displayGeneric = true; this.displayGeneric = true;
// get the style(s) associated with the selected YMM
const styleOptions = await this.mainStore.getVehicleStyles( const styleOptions = await this.mainStore.getVehicleStyles(
vehicle.data.year, vehicle.data.year,
vehicle.data.make, vehicle.data.make,