diff --git a/src/layouts/address-lookup/address-lookup.vue b/src/layouts/address-lookup/address-lookup.vue index 081be8def..f79ee5667 100644 --- a/src/layouts/address-lookup/address-lookup.vue +++ b/src/layouts/address-lookup/address-lookup.vue @@ -355,7 +355,15 @@ export default { } } else { // No VINS found. - this.displayVinNotFoundAlert = true; + const isVinLookupRequired = this.$store.getters.vehicle.vinRequired; + if (isVinLookupRequired) { + this.continueWithFailedLookup( + this.customerQuestions, + resultMap.serviceZipValidationResponse + ); + } else { + this.displayVinNotFoundAlert = true; + } return this.$refs.navbar.removeLoader(); } @@ -462,6 +470,28 @@ export default { this.displayVinLookupByHomeAddressNotAllowedAlert = false; this.displayNoServiceAlert = false; }, + async continueWithFailedLookup(customerQuestions, zipCodeValidationResponse) { + // Save the entered customer questions and service zip code (if applicable) so that it can be used in the next page if needed + await this.dispatchStoreAction( + this.storeActions.SAVE_CUSTOMER_DETAILS, + { + firstName: customerQuestions.firstName, + lastName: customerQuestions.lastName, + }, + false + ); + await this.dispatchStoreAction( + storeActions.SAVE_SERVICE_ZIP_CODE_INFO, + { + state: zipCodeValidationResponse.state, + zipCode: this.serviceZipCode || this.customerQuestions.addressQuestions.zipCode, + zipCodeCtu: zipCodeValidationResponse.zipCodeCtu, + }, + false + ); + + this.navigateForwardWithSingleCarMatch(); + }, }, mounted() { this.attachCustomEvents(); diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.vue b/src/layouts/license-plate-lookup/license-plate-lookup.vue index a1477a664..a3873e437 100644 --- a/src/layouts/license-plate-lookup/license-plate-lookup.vue +++ b/src/layouts/license-plate-lookup/license-plate-lookup.vue @@ -254,7 +254,12 @@ export default { resultMap.registrationZipValidationResponse.state ).catch(() => { // No VIN found. - this.displayVinNotFoundAlert = true; + const isVinLookupRequired = this.$store.getters.vehicle.vinRequired; + if (isVinLookupRequired) { + this.continueWithFailedLookup(resultMap.serviceZipValidationResponse); + } else { + this.displayVinNotFoundAlert = true; + } return this.$refs.navbar.removeLoader(); }); // If no VIN was found, stop processing after displaying alert @@ -393,6 +398,18 @@ export default { this.displayInvalidZipAlert = false; this.displayNoServiceAlert = false; }, + async continueWithFailedLookup(zipCodeData) { + await this.dispatchStoreAction( + storeActions.SAVE_SERVICE_ZIP_CODE_INFO, + { + state: zipCodeData.state, + zipCode: this.serviceZipCode || this.registrationZipCode, + zipCodeCtu: zipCodeData.zipCodeCtu, + }, + false + ); + this.navigateForwardWithSingleCarMatch(); + }, }, mounted() { this.attachCustomEvents(); diff --git a/src/layouts/vin-lookup/vin-lookup.spec.js b/src/layouts/vin-lookup/vin-lookup.spec.js index 7a5ba37eb..5fe09edb2 100644 --- a/src/layouts/vin-lookup/vin-lookup.spec.js +++ b/src/layouts/vin-lookup/vin-lookup.spec.js @@ -11,9 +11,20 @@ jest.mock("@/store", () => ({ commit: jest.fn(), dispatch: jest.fn(), getters: { + applicationUser: { + bailoutCode: null, + }, + externalParameterState: { + isExternalParameter: false, + }, + emailOrSms: "email", vehicle: { year: 2019, carId: "C00000", + vin: null, + vinRequired: false, + isBigTruck: false, + canSafeliteService: true, }, order: { serviceLocation: { @@ -23,6 +34,11 @@ jest.mock("@/store", () => ({ emailAddress: "builddigitaltest@safelite.com", }, referralNumber: "666666", + vehicle: { + make: null, + model: null, + year: null, + }, }, payment: { insuranceCoverage: { diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index ae80f670f..67d7a2d3f 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -93,7 +93,8 @@ vinPopulatedOnPageLoad && !isInsuranceVerified && !displayInvalidZipAlert && - !displayNonServiceableZipAlert + !displayNonServiceableZipAlert && + !requiredVinNotFound " alertClass="alert-success" /> @@ -144,6 +145,7 @@ import baseMixin from "@/mixins/base-mixin.js"; import store from "@/store"; import vinPagesMixin from "@/mixins/vin-pages-mixin"; import { routeData } from "@/router/constants/routes"; +import { bailoutCodes } from "@/constants/bailout-codes"; // DEFINE VALIDATION RULES defineRule("zip-required", required(errorMessages.SERVICE_ZIP_REQUIRED)); @@ -202,6 +204,7 @@ export default { displayMatchedDifferentVehicleAlert: false, displayVinScanFailedAlert: false, displayNoServiceAlert: false, + requiredVinNotFound: this.getRequiredVinNotFound(), }; }, methods: { @@ -289,7 +292,13 @@ export default { if (!resultMap.vehicleLookupResponse || !resultMap.zipCodeData.isServiceable) { // If the vehicle result is undefined, the vin entered was invalid. if (!resultMap.vehicleLookupResponse) { - this.displayVinNotFoundAlert = true; + const isVinLookupRequired = this.$store.getters.vehicle.vinRequired; + if (isVinLookupRequired) { + this.requiredVinNotFound = true; + this.continueWithFailedVin(this.vin, resultMap.zipCodeData); + } else { + this.displayVinNotFoundAlert = true; + } } // Check if Service Zip entered is serviceable, if not display an alert @@ -303,18 +312,18 @@ export default { // Check if the CarId is different from the lookup vs what is in state currently. this.isCarIdDifferent = - resultMap.vehicleLookupResponse.carId !== this.$store.getters.vehicle.carId; + resultMap.vehicleLookupResponse?.carId !== this.$store.getters.vehicle.carId; if ( this.isCarIdDifferent && - resultMap.vehicleLookupResponse.carId !== this.previouslyEnteredCarId + resultMap.vehicleLookupResponse?.carId !== this.previouslyEnteredCarId ) { - this.previouslyEnteredCarId = resultMap.vehicleLookupResponse.carId; + this.previouslyEnteredCarId = resultMap.vehicleLookupResponse?.carId; this.customAlertData.vehicleInfo = resultMap.vehicleLookupResponse; this.displayMatchedDifferentVehicleAlert = true; this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId( - resultMap.vehicleLookupResponse.carId, + resultMap.vehicleLookupResponse?.carId, "vin-lookup" ); @@ -486,10 +495,52 @@ export default { this.displayVinNotFoundAlert = false; this.displayVinScanFailedAlert = false; this.displayNoServiceAlert = false; + this.requiredVinNotFound = false; + }, + async continueWithFailedVin(vin, zipCodeData) { + var selectedVehicle = { + vin: vin, + vehicle: { + carId: this.carId, + make: this.$store.getters.order.vehicle.make || null, + model: this.$store.getters.order.vehicle.model || null, + year: this.$store.getters.order.vehicle.year || null, + }, + }; + await this.dispatchStoreAction( + storeActions.SAVE_VIN, + { + vehicleInfo: Object.assign(selectedVehicle.vehicle, { + vin: vin, + }), + isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle, + }, + false + ); + await this.dispatchStoreAction( + storeActions.SAVE_SERVICE_ZIP_CODE_INFO, + { + state: zipCodeData.state, + zipCode: this.serviceZipCode, + zipCodeCtu: zipCodeData.zipCodeCtu, + }, + false + ); + this.navigateForwardWithSingleCarMatch(); + }, + getRequiredVinNotFound() { + // Prevents success alert from showing + var bailoutCode = this.$store.getters.applicationUser.bailoutCode; + var vinRequired = this.$store.getters.vehicle.vinRequired; + if (vinRequired && this.vin && bailoutCode == bailoutCodes.PART_NOT_FOUND) { + return true; + } + return false; }, }, - mounted() { + async mounted() { this.attachCustomEvents(); + this.requiredVinNotFound = this.getRequiredVinNotFound(); }, computed: { AlertMatchedDifferentVehicleHeader() { diff --git a/src/mixins/vin-pages-mixin.js b/src/mixins/vin-pages-mixin.js index c593d88b4..78cb134cf 100644 --- a/src/mixins/vin-pages-mixin.js +++ b/src/mixins/vin-pages-mixin.js @@ -38,7 +38,10 @@ export default { }); if (result.PartNotFound) { - bailoutMixin.methods.navigateToBailoutPage(this, bailoutCodes.PART_NOT_FOUND); + return bailoutMixin.methods.navigateToBailoutPage( + this, + bailoutCodes.PART_NOT_FOUND + ); } const partsOrQuestions = result.data.partsOrQuestions; diff --git a/src/router/constants/routing-table.js b/src/router/constants/routing-table.js index ea2020a21..3a5d12860 100644 --- a/src/router/constants/routing-table.js +++ b/src/router/constants/routing-table.js @@ -181,6 +181,10 @@ const routingTable = function () { scenario: navigationScenarios.CLICKED_VIN_RETRY, destinationPageData: routeData.ESTIMATE, }, + { + scenario: navigationScenarios.BAILOUT, + destinationPageData: routeData.BAILOUT, + }, ], }, {