CASH-761
mobile location validation
This commit is contained in:
parent
22ab7632a5
commit
b5dbcb07db
2 changed files with 24 additions and 6 deletions
|
|
@ -1435,6 +1435,7 @@ function setupMocks({ mountOptionsMockData = {} }) {
|
||||||
const wrapper = shallowMount(serviceLocation, mountOptions);
|
const wrapper = shallowMount(serviceLocation, mountOptions);
|
||||||
wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent;
|
wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent;
|
||||||
wrapper.vm.$refs.mobileLocationQuestions.isMobileAddressComplete = jest.fn();
|
wrapper.vm.$refs.mobileLocationQuestions.isMobileAddressComplete = jest.fn();
|
||||||
|
wrapper.vm.$refs.mobileLocationQuestions.resetAlerts = jest.fn();
|
||||||
wrapper.vm.$refs.mobileLocationQuestions.openModal = jest.fn();
|
wrapper.vm.$refs.mobileLocationQuestions.openModal = jest.fn();
|
||||||
return { wrapper, apiPromise };
|
return { wrapper, apiPromise };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -174,13 +174,20 @@ const MOBILE_FEE_PART_TYPE = "MOBILE FEE";
|
||||||
|
|
||||||
// DEFINE VALIDATION RULES
|
// DEFINE VALIDATION RULES
|
||||||
defineRule("mobile-location-required", (value) => {
|
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 (
|
if (
|
||||||
value.isMobileSelected &&
|
value.isMobileSelected &&
|
||||||
(!value.addressQuestions.streetAddress ||
|
filledFields.length > 0 &&
|
||||||
!value.addressQuestions.city ||
|
filledFields.length < addressQuestionsValues.length
|
||||||
!value.addressQuestions.state ||
|
|
||||||
!value.addressQuestions.zipCode ||
|
|
||||||
!value.isVehicleProtected)
|
|
||||||
) {
|
) {
|
||||||
return errorMessages.MOBILE_LOCATION_REQUIRED;
|
return errorMessages.MOBILE_LOCATION_REQUIRED;
|
||||||
}
|
}
|
||||||
|
|
@ -780,8 +787,18 @@ export default {
|
||||||
this.selectedProvider = new Provider(
|
this.selectedProvider = new Provider(
|
||||||
this.shopProviderData.mobileProviderNumber
|
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 {
|
} else {
|
||||||
this.selectedProvider = new Provider();
|
this.selectedProvider = new Provider();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue