From e2c5fa96337e58cd4e62a9541c8e5eef6e37a291 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Wed, 15 Jun 2022 13:38:40 -0400 Subject: [PATCH] Fixed bug where we were not correctly checking the zip field when the vin was already populated --- src/layouts/vin-lookup/vin-lookup.vue | 47 +++++++++++++++++---------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index aaf2d016c..036277395 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -143,6 +143,7 @@ import { Form, defineRule } from "vee-validate"; import { navigateAfterSaveToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper"; import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper"; import vinPagesMixin from "@/mixins/vin-pages-mixin"; +import { StatusCodes } from 'http-status-codes'; // DEFINE VALIDATION RULES defineRule("zip-required", required(errorMessages.SERVICE_ZIP_REQUIRED)); @@ -203,6 +204,9 @@ export default { this.getCmsContent("FunnelFooterWidget", "ForwardButtonText") ); }, + initialVin() { + console.log("initial vin change"); + }, }, computed: { perfectMatchNewVinAlert() { @@ -260,7 +264,7 @@ export default { }, setupVinMask() { 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() { return store.getters.vehicle.carId !== null; @@ -305,26 +309,9 @@ export default { } }, 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 vehicleLookup = this.lookupVehicle(this.vin); - 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) { this.customAlertData.zip = this.zip; @@ -334,6 +321,30 @@ export default { 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; if (this.isCarIdDifferent && (vehicleLookupResponse.data.carId !== this.previouslyEnteredCarId)) {