Merge pull request #919 from Safelite/bug/SSR-2004

More robust handling of vehicle YMMS lookup errors
This commit is contained in:
AHumphriesSL 2024-12-23 13:53:31 -05:00 committed by GitHub
commit 64e1cfdc09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 57 additions and 8 deletions

View file

@ -65,10 +65,23 @@ const bailoutMessage = Object.freeze({
code: bailoutCode.SafeliteNotTheProvider, code: bailoutCode.SafeliteNotTheProvider,
message: 'User selected to continue a referral where a TPA shop was previously selected.' message: 'User selected to continue a referral where a TPA shop was previously selected.'
}), }),
vehicleYMMSLookupError: (year, make, model, style, error) => ({ vehicleYMMSLookupError: (year, make, model, style, error) => {
code: bailoutCode.VehicleYMMSLookupError, const baseMessage = "An error occurred looking up vehicle";
message: `An error occurred looking up Year: ${year}, Make: ${make}, Model: ${model}, Style: ${style}. Error: ${getItemData(error)}` const errorMessage = `Error: ${getItemData(error)}`;
}),
const getMessage = (year, make, model, style) => {
if (!year) return `${baseMessage} years. ${errorMessage}`;
if (!make) return `${baseMessage} makes for Year: ${year}. ${errorMessage}`;
if (!model) return `${baseMessage} models for Year: ${year}, Make: ${make}. ${errorMessage}`;
if (!style) return `${baseMessage} styles for Year: ${year}, Make: ${make}, Model: ${model}. ${errorMessage}`;
return `${baseMessage} with Year: ${year}, Make: ${make}, Model: ${model}, Style: ${style}. ${errorMessage}`;
};
return {
code: bailoutCode.VehicleYMMSLookupError,
message: getMessage(year, make, model, style)
};
},
}); });
export default bailoutMessage; export default bailoutMessage;

View file

@ -218,16 +218,52 @@ export default {
}); });
}, },
async updateYearValues() { async updateYearValues() {
return useMainStore().getVehicleYears(); return this.mainStore.getVehicleYears().then((response) => {
return response;
},
(error) => {
this.mainStore.setBailout(bailoutMessage.vehicleYMMSLookupError(null, null, null, null, error));
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
this.$route
);
});
}, },
async updateMakeValues() { async updateMakeValues() {
return this.mainStore.getVehicleMakes(); return this.mainStore.getVehicleMakes().then((response) => {
return response;
},
(error) => {
this.mainStore.setBailout(bailoutMessage.vehicleYMMSLookupError(this.mainStore.vehicle.year, null, null, null, error));
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
this.$route
);
});
}, },
async updateModelValues() { async updateModelValues() {
return this.mainStore.getVehicleModels(); return this.mainStore.getVehicleModels().then((response) => {
return response;
},
(error) => {
this.mainStore.setBailout(bailoutMessage.vehicleYMMSLookupError(this.mainStore.vehicle.year, this.mainStore.vehicle.make, null, null, error));
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
this.$route
);
});
}, },
async updateStyleValues() { async updateStyleValues() {
return this.mainStore.getVehicleStyles(); return this.mainStore.getVehicleStyles().then((response) => {
return response;
},
(error) => {
this.mainStore.setBailout(bailoutMessage.vehicleYMMSLookupError(this.mainStore.vehicle.year, this.mainStore.vehicle.make, this.mainStore.vehicle.model, null, error));
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
this.$route
);
});
} }
} }
}; };