Fixed bug where we were not correctly checking the zip field when the vin was already populated
This commit is contained in:
parent
a32b401418
commit
e2c5fa9633
1 changed files with 29 additions and 18 deletions
|
|
@ -143,6 +143,7 @@ import { Form, defineRule } from "vee-validate";
|
||||||
import { navigateAfterSaveToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
import { navigateAfterSaveToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
||||||
import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper";
|
import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper";
|
||||||
import vinPagesMixin from "@/mixins/vin-pages-mixin";
|
import vinPagesMixin from "@/mixins/vin-pages-mixin";
|
||||||
|
import { StatusCodes } from 'http-status-codes';
|
||||||
|
|
||||||
// DEFINE VALIDATION RULES
|
// DEFINE VALIDATION RULES
|
||||||
defineRule("zip-required", required(errorMessages.SERVICE_ZIP_REQUIRED));
|
defineRule("zip-required", required(errorMessages.SERVICE_ZIP_REQUIRED));
|
||||||
|
|
@ -203,6 +204,9 @@ export default {
|
||||||
this.getCmsContent("FunnelFooterWidget", "ForwardButtonText")
|
this.getCmsContent("FunnelFooterWidget", "ForwardButtonText")
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
initialVin() {
|
||||||
|
console.log("initial vin change");
|
||||||
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
perfectMatchNewVinAlert() {
|
perfectMatchNewVinAlert() {
|
||||||
|
|
@ -260,7 +264,7 @@ export default {
|
||||||
},
|
},
|
||||||
setupVinMask() {
|
setupVinMask() {
|
||||||
const lastSixChars = this.initialVin.substring(11, this.initialVin.length);
|
const lastSixChars = this.initialVin.substring(11, this.initialVin.length);
|
||||||
this.vinMask = `!X!X!X!X!X!X!X!X!X!X!X${lastSixChars}`;
|
this.vinMask = `!X!X!X!X!X!X!X!X!X!X!X${lastSixChars}`;
|
||||||
},
|
},
|
||||||
arePagePrerequisitesValid() {
|
arePagePrerequisitesValid() {
|
||||||
return store.getters.vehicle.carId !== null;
|
return store.getters.vehicle.carId !== null;
|
||||||
|
|
@ -305,26 +309,9 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
// If there is no change to the VIN entered then navigate forward without performing lookup.
|
|
||||||
if (this.vinPopulatedOnPageLoad && this.vin == this.initialVin) {
|
|
||||||
this.navigateForward();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const zipValidation = this.validateZip(this.zip);
|
const zipValidation = this.validateZip(this.zip);
|
||||||
const vehicleLookup = this.lookupVehicle(this.vin);
|
|
||||||
|
|
||||||
const zipValidationResponse = await zipValidation;
|
const zipValidationResponse = await zipValidation;
|
||||||
const vehicleLookupResponse = await vehicleLookup.catch(() => {
|
|
||||||
this.vinNotFound = true;
|
|
||||||
this.$refs.funnelFooter.removeLoader();
|
|
||||||
this.noServiceZip = false;
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!vehicleLookupResponse) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!zipValidationResponse.data.isServiceable) {
|
if (!zipValidationResponse.data.isServiceable) {
|
||||||
this.customAlertData.zip = this.zip;
|
this.customAlertData.zip = this.zip;
|
||||||
|
|
@ -334,6 +321,30 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the vin has been touched and we've gotten this far it means they've entered vin or it's already been entered.
|
||||||
|
let vehicleLookupResponse;
|
||||||
|
if (this.vinTouched && this.vin != this.initialVin) {
|
||||||
|
console.log(this.vin);
|
||||||
|
|
||||||
|
const vinToLookup = this.vinTouched ? this.vin : this.initialVin;
|
||||||
|
const vehicleLookup = this.lookupVehicle(vinToLookup);
|
||||||
|
vehicleLookupResponse = await vehicleLookup.catch((response) => {
|
||||||
|
if (response.status == StatusCodes.NOT_FOUND) {
|
||||||
|
this.vinNotFound = true;
|
||||||
|
this.$refs.funnelFooter.removeLoader();
|
||||||
|
this.noServiceZip = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!vehicleLookupResponse) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.navigateForward();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.isCarIdDifferent = vehicleLookupResponse.data.carId !== store.getters.vehicle.carId;
|
this.isCarIdDifferent = vehicleLookupResponse.data.carId !== store.getters.vehicle.carId;
|
||||||
|
|
||||||
if (this.isCarIdDifferent && (vehicleLookupResponse.data.carId !== this.previouslyEnteredCarId)) {
|
if (this.isCarIdDifferent && (vehicleLookupResponse.data.carId !== this.previouslyEnteredCarId)) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue