From ece57def136c0c18dd507daf6ff32268f28dfa5e Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Thu, 9 Jun 2022 16:45:36 -0400 Subject: [PATCH] Halfway through - highly notated fields --- src/layouts/vin-lookup/vin-lookup.vue | 56 +++++++++++++-------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 9dc81f719..74eb2352e 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -209,9 +209,11 @@ export default { return text; }, MatchedDifferentVehicleAlertBody(){ - const text = this.getCmsContent("MatchedDifferentVehicle", - "BodyText").replaceAll("{custom:damage}", getDamageString()).replaceAll("{custom:vinlookupYear}", this.customAlertData?.vehicleInfo?.year).replaceAll("{custom:vinlookupMake}", this.customAlertData?.vehicleInfo?.make).replaceAll("{custom:vinlookupModel}", - this.customAlertData?.vehicleInfo?.model); + const text = this.getCmsContent("MatchedDifferentVehicle", "BodyText") + .replaceAll("{custom:damage}", getDamageString()) + .replaceAll("{custom:vinlookupYear}", this.customAlertData?.vehicleInfo?.year) + .replaceAll("{custom:vinlookupMake}", this.customAlertData?.vehicleInfo?.make) + .replaceAll("{custom:vinlookupModel}", this.customAlertData?.vehicleInfo?.model); return text; }, @@ -287,47 +289,43 @@ export default { async forwardButtonAction() { const zipValidation = this.validateZip(this.zip); const vehicleLookup = this.lookupVehicle(this.vin); + // await responses below to let above service calls run asynchronously 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; + // validations + if (!vehicleLookupResponse) { // vehicle response is null or false (it fails) + this.vinNotFound = true; // used to determine alerts that show this.$refs.funnelFooter.removeLoader(); - this.noServiceZip = true; - this.invalidZip = this.zip; - return; - } - this.isCarIdDifferent = vehicleLookupResponse.data.carId !== store.getters.vehicle.carId; - - if (this.isCarIdDifferent && (vehicleLookupResponse.data.carId !== this.previouslyEnteredCarId)) { - this.previouslyEnteredCarId = vehicleLookupResponse.data.carId; - this.noServiceZip = false; - this.customAlertData.vehicleInfo = vehicleLookupResponse.data; + this.noServiceZip = false; // used to determine alerts that show + } else if (!zipValidationResponse.data.isServiceable) { // zip response shows zip is not serviceable + this.$refs.funnelFooter.removeLoader(); + this.noServiceZip = true; // used to determine alerts that show + this.invalidZip = this.zip; // used to populate the alert + } else if (vehicleLookupResponse.data.carId !== store.getters.vehicle.carId && // response does not match what was selected previously in the flow && + (vehicleLookupResponse.data.carId !== this.previouslyEnteredCarId)) // response does not match what was returned from a previous response + { + this.isCarIdDifferent = true; // because vehicleLookupResponse.data.carId !== store.getters.vehicle.carId + this.previouslyEnteredCarId = vehicleLookupResponse.data.carId; // tracks if car ID is different since last time we got a vehicle lookup response + this.noServiceZip = false; // used to determine alerts that show + this.customAlertData.vehicleInfo = vehicleLookupResponse.data; // populate the vehicle info alert info this.$refs.funnelFooter.updateButtonText(`Continue with ${vehicleLookupResponse.data.year} ${vehicleLookupResponse.data.make} ${vehicleLookupResponse.data.model}`); - this.isVinValid = true; + this.isVinValid = true; //I don't think this line is needed this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(vehicleLookupResponse.data.carId); this.$refs.funnelFooter.removeLoader(); - this.isCarIdDifferent = true; - return; + } else { + this.isCarIdDifferent = vehicleLookupResponse.data.carId !== store.getters.vehicle.carId; // do I need this line? -- I do + this.updateStore(vehicleLookupResponse.data, zipValidationResponse.data); + this.navigateForward(); } - this.updateStore(vehicleLookupResponse.data, zipValidationResponse.data); - this.navigateForward(); }, navigateForward(){ - if(this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle){ + if(this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle){ // does it matter if the carId is different here? would we ever go forward if we didn't have glass match? -- it does this.$router.navigateAfterSave(this.navigationScenarios.CLICKED_FORWARD, this.$route, {}, { displayVehicleChangeAlert: true }, {}); - return; } else { this.$refs.loadingModal.showModal(); navigateAfterSaveToHeritageFunnel(this.$route); - return; } }, validateZip(zip) {