Merge pull request #568 from Safelite/feature/CSR-659

Feature/csr 659
This commit is contained in:
Leah Schumann 2022-06-16 14:47:18 -04:00 committed by GitHub
commit 7398eeb81a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,6 +27,7 @@
maxLength="17" maxLength="17"
:mask="vinMask" :mask="vinMask"
@focus="setVinTouched" @focus="setVinTouched"
@maska="rawVinValue = $event.target.dataset.maskRawValue"
/> />
</div> </div>
</div> </div>
@ -188,6 +189,7 @@ export default {
vinPopulatedOnPageLoad: this.getVinFromStore()?.length > 0, vinPopulatedOnPageLoad: this.getVinFromStore()?.length > 0,
initialVin: this.getVinFromStore(), initialVin: this.getVinFromStore(),
vinTouched: false, vinTouched: false,
rawVinValue: "",
}; };
}, },
mounted() { mounted() {
@ -209,7 +211,8 @@ export default {
}, },
computed: { computed: {
perfectMatchNewVinAlert() { 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); this.updateIsCarIdDifferent(isVinPerfectMatch);
return isVinPerfectMatch; return isVinPerfectMatch;
}, },
@ -308,23 +311,18 @@ export default {
} }
}, },
async forwardButtonAction() { async forwardButtonAction() {
let zipValidationResponse;
let vehicleLookupResponse;
const zipValidation = this.validateZip(this.zip); 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. // 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 vinToLookup = this.vinTouched ? this.vin : this.initialVin;
const vehicleLookup = this.lookupVehicle(vinToLookup); const vehicleLookup = this.lookupVehicle(vinToLookup);
zipValidationResponse = await zipValidation;
vehicleLookupResponse = await vehicleLookup.catch((response) => { vehicleLookupResponse = await vehicleLookup.catch((response) => {
if (response.status == StatusCodes.NOT_FOUND) { if (response.status == StatusCodes.NOT_FOUND) {
this.vinNotFound = true; 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. // Check if Service Zip entered is servicable, if not display an alert
if (!zipValidationResponse.data.isServiceable || !vehicleLookupResponse) { if (!zipValidationResponse.data.isServiceable) {
this.customAlertData.zip = this.zip;
this.noServiceZip = true;
this.invalidZip = this.zip;
}
if (!vehicleLookupResponse || !zipValidationResponse.data.isServiceable) {
this.$refs.funnelFooter.removeLoader(); this.$refs.funnelFooter.removeLoader();
return; return;
} }
} else { } else {
// if the ZIP is not serviceable then don't navigate forward. const zipValidationResponse = await zipValidation;
// Check if Service Zip entered is serviceable, if not display an alert
if (!zipValidationResponse.data.isServiceable) { if (!zipValidationResponse.data.isServiceable) {
this.customAlertData.zip = this.zip;
this.noServiceZip = true;
this.invalidZip = this.zip;
this.$refs.funnelFooter.removeLoader(); this.$refs.funnelFooter.removeLoader();
return;
} else {
this.navigateForward();
return; return;
} }
}
this.navigateForward(); if (!vehicleLookupResponse) {
return; return;
} }