fix for mismatched vehicle - navigates to correct page

This commit is contained in:
Kroell 2023-01-20 14:06:42 -05:00
parent 853a7affe7
commit 8da1c0c7c8

View file

@ -108,8 +108,6 @@ export default {
vehicleFromLookup: null, vehicleFromLookup: null,
licensePlate: null, licensePlate: null,
licenseState: null, licenseState: null,
registrationZipCode: null,
serviceZipCode: this.serviceZipCode,
displayVinNotFoundAlert: false, displayVinNotFoundAlert: false,
displayMatchedDifferentVehicleAlert: false, displayMatchedDifferentVehicleAlert: false,
previouslyEnteredCarId: "", previouslyEnteredCarId: "",
@ -123,7 +121,7 @@ export default {
return this.mainStore.order.vehicle.carId !== null; return this.mainStore.order.vehicle.carId !== null;
}, },
loadDefaultsFromStore() { loadDefaultsFromStore() {
this.customerQuestions = this.mainStore.customerData.addressQuestions.zipCode; this.customerQuestions = this.mainStore.customerData.addressQuestions.state;
}, },
backButtonAction() { backButtonAction() {
// route to move backwards // route to move backwards
@ -144,48 +142,30 @@ export default {
this.resetWarningsAndErrors(); this.resetWarningsAndErrors();
// Lookup VIN // Lookup VIN
const vinLookupResponse = useMainStore().lookupVinByPlate({ const vinLookupResponse = await useMainStore().lookupVinByPlate(
licensePlate: this.customerQuestions.licensePlate, this.licensePlate, this.licenseState);
licenseState: this.licenseState,
});
const registrationZipValidationResponse = useMainStore().validateZip( { zip: this.registrationZipCode });
// Settle promises and get results // Settle promises and get results
const promiseResultMap = [ const promiseResultMap = [
{ {
resultKey: "vinLookupResponse", resultKey: "vinLookupResponse",
promise: vinLookupResponse, promise: vinLookupResponse,
}, },
{
resultKey: "registrationZipValidationResponse",
promise: registrationZipValidationResponse,
},
{
// If serviceZipCode is not set, then sets the response to the registrationZipValidationResponse. Calls VALIDATE_ZIP if the serviceZipCode is set.
resultKey: "serviceZipValidationResponse",
promise: this.serviceZipCode
? useMainStore().validateZip({zip: this.serviceZipCode})
: registrationZipValidationResponse,
},
]; ];
const resultMap = await settleAllPromises(promiseResultMap); const resultMap = await settleAllPromises(promiseResultMap);
// No VIN found // No VIN found
if (resultMap.vinLookupResponse.error) { if (resultMap.vinLookupResponse.error) {
this.displayVinNotFoundAlert = true; this.displayVinNotFoundAlert = true;
this.$refs.siteFooter.disableForwardButton(); this.$refs.siteFooter.disableForwardButton();
return this.$refs.siteFooter.removeLoader(); return this.$refs.siteFooter.removeLoader();
} };
// If no VIN was found, stop processing after displaying alert
if (!resultMap.vinLookupResponse) {
return;
}
// Vehicle found from VIN lookup
const vehicleFromLookup = resultMap.vinLookupResponse.vehicle; const vehicleFromLookup = resultMap.vinLookupResponse.vehicle;
// Check if the CarId has changed. // Check if the CarId has changed
this.isCarIdDifferent = this.isCarIdDifferent =
vehicleFromLookup.carId !== useMainStore().order.vehicle.carId; vehicleFromLookup.carId !== useMainStore().order.vehicle.carId;
// Handle changing car // Handle changing car
@ -198,7 +178,7 @@ export default {
this.customAlertData.vehicleInfo = vehicleFromLookup; this.customAlertData.vehicleInfo = vehicleFromLookup;
this.displayMatchedDifferentVehicleAlert = true; this.displayMatchedDifferentVehicleAlert = true;
this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId( this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(
vehicleFromLookup.carId vehicleFromLookup.carId
); );
// Update button "Continue with..." // Update button "Continue with..."
@ -212,11 +192,10 @@ export default {
await useMainStore().saveRegistrationLicensePlateLookup( await useMainStore().saveRegistrationLicensePlateLookup(
{ {
isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle, isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle,
vehicleInfo: Object.assign(this.mainStore.order.vehicle), vehicleInfo: Object.assign(vehicleFromLookup, {vin: vehicleFromLookup.vin }),
registrationInfo: { registrationInfo: {
licensePlate: this.licensePlate, licensePlate: this.licensePlate,
state: resultMap.registrationZipValidationResponse.state, state: this.licenseState,
zipCode: this.registrationZipCode,
}, },
}, },
false false