From 597c67da93c133e0e51811b6211eebaced213b19 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Thu, 16 Jun 2022 14:29:58 -0400 Subject: [PATCH] Reestablished simultaneous calls to VIN Lookup and Zip Validation --- src/layouts/vin-lookup/vin-lookup.vue | 59 +++++++++++++++++---------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 23cce0f67..392cde7f1 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -27,6 +27,7 @@ maxLength="17" :mask="vinMask" @focus="setVinTouched" + @maska="rawVinValue = $event.target.dataset.maskRawValue" /> @@ -188,6 +189,7 @@ export default { vinPopulatedOnPageLoad: this.getVinFromStore()?.length > 0, initialVin: this.getVinFromStore(), vinTouched: false, + rawVinValue: "", }; }, mounted() { @@ -209,7 +211,8 @@ export default { }, computed: { perfectMatchNewVinAlert() { - const isVinPerfectMatch = this.vinPopulatedOnPageLoad && this.initialVin === this.getVinFromStore(); + const vinToCheck = this.vinTouched ? this.rawVinValue : this.initialVin; + const isVinPerfectMatch = this.vinPopulatedOnPageLoad && vinToCheck === this.getVinFromStore(); this.updateIsCarIdDifferent(isVinPerfectMatch); return isVinPerfectMatch; }, @@ -308,23 +311,18 @@ export default { } }, async forwardButtonAction() { + let zipValidationResponse; + let vehicleLookupResponse; const zipValidation = this.validateZip(this.zip); - const zipValidationResponse = await zipValidation; - - // Check if Service Zip entered is servicable, if not display an alert - if (!zipValidationResponse.data.isServiceable) { - this.customAlertData.zip = this.zip; - this.noServiceZip = true; - this.invalidZip = this.zip; - } - let vehicleLookupResponse; - if (this.vinTouched && this.vin != this.initialVin) { + if (this.vinTouched && this.vin != this.initialVin) { // If the user has clicked on the VIN field, either they are doing a new VIN lookup or changing the VIN previously matched. - // Therefore we need to do a VIN Lookup + // Therefore we need to do a Vehicle Lookup const vinToLookup = this.vinTouched ? this.vin : this.initialVin; const vehicleLookup = this.lookupVehicle(vinToLookup); + + zipValidationResponse = await zipValidation; vehicleLookupResponse = await vehicleLookup.catch((response) => { if (response.status == StatusCodes.NOT_FOUND) { this.vinNotFound = true; @@ -333,19 +331,36 @@ export default { } }); - // if the ZIP is not serviceable or the Vin Lookup didn't return anything then don't complete the process and navigate forward. - if (!zipValidationResponse.data.isServiceable || !vehicleLookupResponse) { - this.$refs.funnelFooter.removeLoader(); - return; - } - } else { - // if the ZIP is not serviceable then don't navigate forward. + // Check if Service Zip entered is servicable, if not display an alert if (!zipValidationResponse.data.isServiceable) { - this.$refs.funnelFooter.removeLoader(); - return; + this.customAlertData.zip = this.zip; + this.noServiceZip = true; + this.invalidZip = this.zip; } + + if (!vehicleLookupResponse || !zipValidationResponse.data.isServiceable) { + this.$refs.funnelFooter.removeLoader(); + return; + } + } else { + const zipValidationResponse = await zipValidation; + + // Check if Service Zip entered is serviceable, if not display an alert + if (!zipValidationResponse.data.isServiceable) { + this.customAlertData.zip = this.zip; + this.noServiceZip = true; + this.invalidZip = this.zip; + this.$refs.funnelFooter.removeLoader(); - this.navigateForward(); + return; + + } else { + this.navigateForward(); + return; + } + } + + if (!vehicleLookupResponse) { return; }