From 4ae40b9439548d4c659e53c4c0c331479d7d3758 Mon Sep 17 00:00:00 2001 From: FrankRua Date: Wed, 6 Jul 2022 12:37:47 -0400 Subject: [PATCH] some small changes, fixed one defect --- src/layouts/address-lookup/address-lookup.vue | 18 ++++++------- .../address-vehicles/address-vehicles.vue | 5 +++- .../license-plate-lookup.vue | 16 ++++++------ src/layouts/vin-lookup/vin-lookup.vue | 12 ++++----- src/store/index.js | 25 ++++++------------- src/store/store.spec.js | 7 +----- 6 files changed, 36 insertions(+), 47 deletions(-) diff --git a/src/layouts/address-lookup/address-lookup.vue b/src/layouts/address-lookup/address-lookup.vue index ddbecc5c8..849e5772f 100644 --- a/src/layouts/address-lookup/address-lookup.vue +++ b/src/layouts/address-lookup/address-lookup.vue @@ -251,13 +251,8 @@ export default { // Save vehicle, customer, service and registration information await this.dispatchStoreAction(storeActions.SAVE_REGISTRATION_ADDRESS_LOOKUP, { - isCarIdDifferent: this.isCarIdDifferent, isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle, - vehicleInfo: vehicleInfoToCommit, - serviceLocationInfo: { - zipCode: this.serviceZipCode, - state: resultMap.serviceZipValidationResponse.state, - }, + vehicleInfo: Object.keys(vehicleInfoToCommit).length === 0 ? this.$store.getters.vehicle : vehicleInfoToCommit, registrationInfo: { firstName: this.customerQuestions.firstName, lastName: this.customerQuestions.lastName, @@ -265,8 +260,13 @@ export default { city: this.customerQuestions.addressQuestions.city, state: resultMap.serviceZipValidationResponse.state, zipCode: this.customerQuestions.addressQuestions.zipCode - }, - customerEmail: this.customerQuestions.emailAddress, + } + }, false); + + await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.customerQuestions.emailAddress, false); + await this.dispatchStoreAction(storeActions.SAVE_SERVICE_LOCATION, { + zipCode: this.serviceZipCode, + state: resultMap.serviceZipValidationResponse.state, }, false); return await this.navigateForward(carsFound); @@ -277,7 +277,7 @@ export default { // If a different vehicle is found than the one entered and the selected glass is not available for that vehicle then navigate back to "vehicle-damage" // display vehicle changed alert on that page. - console.log(this.isCarIdDifferent,!this.isSelectedGlassAvailableForVehicle,matchingCars.length === 1) + if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle && matchingCars.length === 1) { this.$router.navigate(this.navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, this.$route, {}, {[routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true}); } else if (matchingCars.length === 1) { diff --git a/src/layouts/address-vehicles/address-vehicles.vue b/src/layouts/address-vehicles/address-vehicles.vue index c55b0ab08..aefe84d26 100644 --- a/src/layouts/address-vehicles/address-vehicles.vue +++ b/src/layouts/address-vehicles/address-vehicles.vue @@ -151,6 +151,10 @@ export default { getRouterLinkRouteFromCopy, getRouterLinkDisplayTextFromCopy, arePagePrerequisitesValid() { + console.log(store.getters.order.vehicle.carId + ,store.getters.order.serviceLocation.zipCode + ,store.getters.order.customer.emailAddress + ,store.getters.pageData(fmgPageValues.ADDRESS_VEHICLES)); if ( store.getters.order.vehicle.carId && store.getters.order.serviceLocation.zipCode @@ -177,7 +181,6 @@ export default { await this.dispatchStoreAction(storeActions.SAVE_VIN, { vehicleInfo: Object.assign(this.selectedVehicle.vehicle, { vin: this.selectedVehicle.vin }), - isCarIdDifferent: this.isCarIdDifferent, isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle }, false); diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.vue b/src/layouts/license-plate-lookup/license-plate-lookup.vue index 17868be0e..3e9240719 100644 --- a/src/layouts/license-plate-lookup/license-plate-lookup.vue +++ b/src/layouts/license-plate-lookup/license-plate-lookup.vue @@ -264,7 +264,7 @@ export default { // Check if the CarId has changed. this.isCarIdDifferent = vinLookup.data.vehicle.carId !== this.$store.getters.vehicle.carId; - console.log("here"); + //Handle changing car if (this.isCarIdDifferent && vinLookup.data.vehicle.carId !== this.previouslyEnteredCarId) { this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(vinLookup.data.vehicle.carId); @@ -279,21 +279,21 @@ export default { // Save vin, vehicle, customer, service and registration information await this.dispatchStoreAction(storeActions.SAVE_REGISTRATION_LICENSE_PLATE_LOOKUP, { - isCarIdDifferent: this.isCarIdDifferent, isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle, vehicleInfo: Object.assign(vinLookup.data.vehicle, { vin: vinLookup.data.vin }), - serviceLocationInfo: { - zipCode: this.serviceZip, - state: resultMap.serviceZipValidationResponse.state, - }, registrationInfo: { licensePlate: this.licensePlate, state: resultMap.registrationZipValidationResponse.state, zipCode: this.registrationZip, - }, - customerEmail: this.email, + } }, false); + await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.email, false); + await this.dispatchStoreAction(storeActions.SAVE_SERVICE_LOCATION, { + zipCode: this.serviceZip, + state: resultMap.serviceZipValidationResponse.state, + }, false); + return await this.navigateForward(); }, async navigateForward() { diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 1ba6fb336..d5943ecdb 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -330,15 +330,15 @@ export default { // Save vin, vehicle, customer and service information await this.dispatchStoreAction(storeActions.SAVE_VIN_LOOKUP, { - isCarIdDifferent: this.isCarIdDifferent, isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle, - vehicleInfo: Object.assign(resultMap.vehicleLookupResponse, { vin: this.vin }), - serviceLocationInfo: { + vehicleInfo: Object.assign(resultMap.vehicleLookupResponse, { vin: this.vin }) + }, false); + + await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.email, false); + await this.dispatchStoreAction(storeActions.SAVE_SERVICE_LOCATION, { zipCode: this.zip, state: resultMap.validateZipResponse.state, - }, - customerEmail: this.email, - }, false); + }, false); return await this.navigateForward(); } diff --git a/src/store/index.js b/src/store/index.js index c03421fa8..95c6deac1 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -744,30 +744,27 @@ export const actions = { }, // Vin lookup - saveVinLookup(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo, serviceLocationInfo, customerEmail }) { + saveVinLookup(context, {isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo}) { //Reset dependent state when changing if (vehicleInfo.vin !== context.state.order.vehicle.vin) { context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); - if (isCarIdDifferent && !isSelectedGlassAvailableForVehicle) { + if (!isSelectedGlassAvailableForVehicle) { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); } } //Save new values - context.dispatch(storeActions.SAVE_EMAIL, customerEmail); - context.dispatch(storeActions.SAVE_SERVICE_LOCATION, serviceLocationInfo); - context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo); context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo); }, - saveRegistrationLicensePlateLookup(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo, serviceLocationInfo, customerEmail }) { + saveRegistrationLicensePlateLookup(context, {isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo}) { //Reset dependent state when changing if (registrationInfo?.licensePlate !== context.state.order.vehicle.registration?.licensePlate) { context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); - if (isCarIdDifferent && !isSelectedGlassAvailableForVehicle) { + if (!isSelectedGlassAvailableForVehicle) { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); } } @@ -775,17 +772,14 @@ export const actions = { //Save new values context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo); context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo); - - context.dispatch(storeActions.SAVE_EMAIL, customerEmail); - context.dispatch(storeActions.SAVE_SERVICE_LOCATION, serviceLocationInfo); }, - saveRegistrationAddressLookup(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo, serviceLocationInfo, customerEmail }) { + saveRegistrationAddressLookup(context, {isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo}) { //Reset dependent state when changing if (registrationInfo?.address !== context.state.order.vehicle.registration?.address || registrationInfo?.city !== context.state.order.vehicle.registration?.city || registrationInfo?.state !== context.state.order.vehicle.registration?.state || registrationInfo?.zipCode !== context.state.order.vehicle.registration?.zipCode || registrationInfo?.firstName !== context.state.order.vehicle.registration?.firstName || registrationInfo?.lastName !== context.state.order.vehicle.registration?.lastName) { context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); - if (isCarIdDifferent && !isSelectedGlassAvailableForVehicle) { + if (!isSelectedGlassAvailableForVehicle) { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); } } @@ -793,9 +787,6 @@ export const actions = { //Save new values context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo); context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo); - - context.dispatch(storeActions.SAVE_EMAIL, customerEmail); - context.dispatch(storeActions.SAVE_SERVICE_LOCATION, serviceLocationInfo); }, // Misc order actions @@ -805,11 +796,11 @@ export const actions = { saveEmail(context, email) { context.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, email); }, - saveVin(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo }) { + saveVin(context, {isSelectedGlassAvailableForVehicle, vehicleInfo }) { //Reset dependent state when changing if (vehicleInfo.vin !== context.state.order.vehicle.vin) { - if (isCarIdDifferent && !isSelectedGlassAvailableForVehicle) { + if (!isSelectedGlassAvailableForVehicle) { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); } diff --git a/src/store/store.spec.js b/src/store/store.spec.js index b4a644c3c..960a6d784 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -784,8 +784,7 @@ describe("Actions", () => { // Assert expect(dispatch).toHaveBeenNthCalledWith(1, storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); expect(dispatch).toHaveBeenNthCalledWith(2, storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); - expect(dispatch).toHaveBeenNthCalledWith(3, storeActions.SAVE_EMAIL, payload.customerEmail); - expect(dispatch).toHaveBeenNthCalledWith(4, storeActions.SAVE_SERVICE_LOCATION, payload.serviceLocationInfo); + expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE, payload.vehicleInfo); expect(commit).toBeCalledWith(storeMutations.UPDATE_REGISTRATION, payload.registrationInfo); }); @@ -818,8 +817,6 @@ describe("Actions", () => { // Assert expect(dispatch).toHaveBeenNthCalledWith(1, storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); expect(dispatch).toHaveBeenNthCalledWith(2, storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); - expect(dispatch).toHaveBeenNthCalledWith(3, storeActions.SAVE_EMAIL, payload.customerEmail); - expect(dispatch).toHaveBeenNthCalledWith(4, storeActions.SAVE_SERVICE_LOCATION, payload.serviceLocationInfo); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE, payload.vehicleInfo); expect(commit).toBeCalledWith(storeMutations.UPDATE_REGISTRATION, payload.registrationInfo); @@ -853,8 +850,6 @@ describe("Actions", () => { // Assert expect(dispatch).toHaveBeenNthCalledWith(1, storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); expect(dispatch).toHaveBeenNthCalledWith(2, storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); - expect(dispatch).toHaveBeenNthCalledWith(3, storeActions.SAVE_EMAIL, payload.customerEmail); - expect(dispatch).toHaveBeenNthCalledWith(4, storeActions.SAVE_SERVICE_LOCATION, payload.serviceLocationInfo); expect(commit).toBeCalledWith(storeMutations.UPDATE_VEHICLE, payload.vehicleInfo); expect(commit).toBeCalledWith(storeMutations.UPDATE_REGISTRATION, payload.registrationInfo);