SSR-1373 Fix License-place-lookup bugs

This commit is contained in:
Josh Dassinger 2024-06-24 13:32:39 -05:00
parent 6c30f3b3ab
commit 0d944f155d
2 changed files with 25 additions and 36 deletions

View file

@ -262,18 +262,8 @@ export default {
this.licenseState
);
// Settle promises and get results
const promiseResultMap = [
{
resultKey: 'vinLookupResponse',
promise: vinLookupResponse
}
];
const resultMap = await settleAllPromises(promiseResultMap);
// No VIN found
if (resultMap.vinLookupResponse.error) {
if (vinLookupResponse.error) {
this.displayVinNotFoundAlert = true;
this.previouslyEnteredCarId = null;
this.$refs.siteFooter.disableForwardButton();
@ -281,14 +271,12 @@ export default {
}
// Vehicle found from VIN lookup
const vehicleFromLookup = resultMap.vinLookupResponse.vehicle;
const vehicleFromLookup = vinLookupResponse.data.vehicle;
// Check if the CarId has changed
this.isCarIdDifferent =
vehicleFromLookup.carId !== useMainStore().order.vehicle.carId;
this.isCarIdDifferent = vehicleFromLookup.carId !== useMainStore().order.vehicle.carId;
// Handle changing car
if (
this.isCarIdDifferent
if (this.isCarIdDifferent
&& vehicleFromLookup.carId !== this.previouslyEnteredCarId
) {
// Display Alert
@ -302,8 +290,7 @@ export default {
this.displayMatchedDifferentVehicleAlert = true;
}
this.isSelectedGlassAvailableForVehicle =
await isGlassAvailableForCarId(vehicleFromLookup.carId);
this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(vehicleFromLookup.carId);
// Update button "Continue with..."
this.$refs.siteFooter
@ -313,20 +300,16 @@ export default {
}
// Save vehicle, license plate, and registration information
await useMainStore().saveRegistrationLicensePlateLookup(
{
isSelectedGlassAvailableForVehicle:
this.isSelectedGlassAvailableForVehicle,
vehicleInfo: Object.assign(vinLookupResponse.data.vehicle, {
vin: vinLookupResponse.data.vin
}),
registrationInfo: {
licensePlate: this.licensePlate,
state: this.licenseState
}
},
false
);
useMainStore().saveRegistrationLicensePlateLookup({
isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle,
vehicleInfo: Object.assign(vinLookupResponse.data.vehicle, {
vin: vinLookupResponse.data.vin
}),
registrationInfo: {
licensePlate: this.licensePlate,
state: this.licenseState
}
});
return this.navigateForward();
},
@ -334,8 +317,7 @@ export default {
// If a different vehicle is found than the one entered and the selected glass is
// not available for that vehicle then navigate back to "vehicle-damage"
// display vehicle changed alert on that page.
if (
this.isCarIdDifferent
if (this.isCarIdDifferent
&& !this.isSelectedGlassAvailableForVehicle
) {
this.$router.navigate(

View file

@ -1858,6 +1858,13 @@ export const useMainStore = defineStore({
this.order.vehicle.imageUrl = null;
this.order.vehicle.imageVifNumber = null;
this.order.vehicle.imageColor = null;
this.order.vehicle.registration.licensePlate = null;
this.order.vehicle.registration.state = null;
this.order.vehicle.registration.address = null;
this.order.vehicle.registration.city = null;
this.order.vehicle.registration.zipCode = null;
this.order.vehicle.registration.firstName = null;
this.order.vehicle.registration.lastName = null;
},
resetGlassPartsState() {
@ -2466,9 +2473,9 @@ export const useMainStore = defineStore({
}
},
saveRegistrationLicensePlateLookup({ isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo }) {
// Reset dependent state when changing
// Reset dependent state when changing
if (registrationInfo?.licensePlate !== this.order.vehicle.registration?.licensePlate
|| registrationInfo?.state !== this.order.vehicle.registration?.state) {
|| registrationInfo?.state !== this.order.vehicle.registration?.state) {
this.resetRegistrationAndDependencies();
if (!isSelectedGlassAvailableForVehicle) {