From b5dbcb07db2b0f547372488bb7b10a66a7c5d3a3 Mon Sep 17 00:00:00 2001 From: hiteshkumar87 Date: Wed, 28 May 2025 17:55:38 +0530 Subject: [PATCH] CASH-761 mobile location validation --- .../service-location/service-location.spec.js | 1 + .../service-location/service-location.vue | 29 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/layouts/service-location/service-location.spec.js b/src/layouts/service-location/service-location.spec.js index b80644dc0..58187496e 100644 --- a/src/layouts/service-location/service-location.spec.js +++ b/src/layouts/service-location/service-location.spec.js @@ -1435,6 +1435,7 @@ function setupMocks({ mountOptionsMockData = {} }) { const wrapper = shallowMount(serviceLocation, mountOptions); wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent; wrapper.vm.$refs.mobileLocationQuestions.isMobileAddressComplete = jest.fn(); + wrapper.vm.$refs.mobileLocationQuestions.resetAlerts = jest.fn(); wrapper.vm.$refs.mobileLocationQuestions.openModal = jest.fn(); return { wrapper, apiPromise }; } diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index d4bdae818..3945d5e48 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -174,13 +174,20 @@ const MOBILE_FEE_PART_TYPE = "MOBILE FEE"; // DEFINE VALIDATION RULES defineRule("mobile-location-required", (value) => { + const addressQuestionsValues = Object.values( + [ + value.addressQuestions.streetAddress, + value.addressQuestions.city, + value.isVehicleProtected, + ] || {} + ); + const filledFields = addressQuestionsValues.filter( + (val) => val !== null && val !== undefined && val !== "" + ); if ( value.isMobileSelected && - (!value.addressQuestions.streetAddress || - !value.addressQuestions.city || - !value.addressQuestions.state || - !value.addressQuestions.zipCode || - !value.isVehicleProtected) + filledFields.length > 0 && + filledFields.length < addressQuestionsValues.length ) { return errorMessages.MOBILE_LOCATION_REQUIRED; } @@ -780,8 +787,18 @@ export default { this.selectedProvider = new Provider( this.shopProviderData.mobileProviderNumber ); + if (this.zipCode == this.getServiceZipCodeFromStore()) { + //restore mobile address from store in case user make changes to address but not commit it. + this.streetAddress = this.getServiceAddressFromStore(); + this.apartmentNumberOrBusinessName = this.getServiceAddress2FromStore(); + this.city = this.getServiceCityFromStore(); + this.isVehicleProtected = this.getIsVehicleProtectedFromStore(); + this.$refs.mobileLocationQuestions.resetAlerts(); + } else { + this.resetMobileLocation(); + } } else { - this.selectedProvider = new Provider(); + this.selectedProvider = new Provider(); } }, },