open mobile address when click on mobile option
This commit is contained in:
hiteshkumar87 2025-05-11 12:08:24 +05:30
parent 565c122a31
commit 911a1f0e12
3 changed files with 44 additions and 30 deletions

View file

@ -58,8 +58,9 @@
cmsWidgetName="AlertMismatchStateAndZipWidget" cmsWidgetName="AlertMismatchStateAndZipWidget"
alertClass="alert-danger" alertClass="alert-danger"
v-bind:isDismissible="false" /> v-bind:isDismissible="false" />
</div> </div>
</div> </div>
</transition>
</template> </template>
<script> <script>
// Components // Components
@ -90,8 +91,7 @@ export default {
"updated-contains-military-base", "updated-contains-military-base",
"updated-bill-to-account-number", "updated-bill-to-account-number",
"setMobileLocation", "setMobileLocation",
"set-mobile-location-invalid", "set-mobile-location-invalid",
"updated-modal-opened",
], ],
data() { data() {
return { return {
@ -208,10 +208,28 @@ export default {
}, },
}, },
methods: { methods: {
isMobileAddressComplete() {
return (
this.addressModel.streetAddress &&
this.addressModel.streetAddress !== "" &&
this.addressModel.city &&
this.addressModel.city !== "" &&
this.addressModel.state &&
this.addressModel.state !== "" &&
this.addressModel.zipCode &&
this.addressModel.zipCode !== "" &&
this.internalModel.isVehicleProtected !== null
);
},
getIsMobleLocationOpened() {
if (this.isServiceAddressFromStoreAvailable) {
return false;
}
return true;
},
setMobileLocationInvalid(isFormInvalid) { setMobileLocationInvalid(isFormInvalid) {
this.$emit("set-mobile-location-invalid", isFormInvalid); this.$emit("set-mobile-location-invalid", isFormInvalid);
} },
resetAlerts() { resetAlerts() {
this.displayInvalidZipAlert = false; this.displayInvalidZipAlert = false;
this.displayMismatchStateAndZipAlert = false; this.displayMismatchStateAndZipAlert = false;
@ -282,12 +300,19 @@ export default {
}, },
watch: { watch: {
internalModel: { internalModel: {
handler(newValue) { handler() {
this.handleChange(newValue);
this.setMobileLocation(); this.setMobileLocation();
}, },
deep: true, deep: true,
}, },
modelValue: {
handler(newValue) {
this.internalModel = deepClone(newValue);
this.handleChange(newValue);
},
deep: true,
},
}, },
components: { components: {
addressQuestions, addressQuestions,

View file

@ -343,7 +343,6 @@ describe("service-location.vue", () => {
zipCode: "43054", zipCode: "43054",
}, },
isVehicleProtected: true, isVehicleProtected: true,
isMobileSelectedAndModalClosed: true,
}; };
wrapper.vm.mobileLocationQuestions = mobileLocationQuestions; wrapper.vm.mobileLocationQuestions = mobileLocationQuestions;
@ -356,7 +355,6 @@ describe("service-location.vue", () => {
zipCode: "61606", zipCode: "61606",
}, },
isVehicleProtected: null, isVehicleProtected: null,
isMobileSelectedAndModalClosed: false,
}; };
// Act // Act
@ -459,7 +457,6 @@ describe("service-location.vue", () => {
zipCode: "", zipCode: "",
}, },
isVehicleProtected: null, isVehicleProtected: null,
isMobileSelectedAndModalClosed: false,
}; };
wrapper.vm.mobileLocationQuestions = mobileLocationQuestions; wrapper.vm.mobileLocationQuestions = mobileLocationQuestions;
const newMobileLocationQuestions = { const newMobileLocationQuestions = {
@ -471,7 +468,6 @@ describe("service-location.vue", () => {
zipCode: "43054", zipCode: "43054",
}, },
isVehicleProtected: true, isVehicleProtected: true,
isMobileSelectedAndModalClosed: true,
}; };
//wrapper.vm.closeModalAction = jest.fn(); //wrapper.vm.closeModalAction = jest.fn();

View file

@ -100,7 +100,6 @@
@updated-serviceability="setServiceabilityDetails" @updated-serviceability="setServiceabilityDetails"
@updated-contains-military-base="setContainsMilitaryBase" @updated-contains-military-base="setContainsMilitaryBase"
@updated-mobile-ctu="setCtuForMobile" @updated-mobile-ctu="setCtuForMobile"
@updated-modal-opened="setMobileLocationModalOpened"
validationRules="mobile-location-required" validationRules="mobile-location-required"
ref="mobileLocationQuestions" ref="mobileLocationQuestions"
linkWidgetName="MobileLocationLinkWidget" linkWidgetName="MobileLocationLinkWidget"
@ -123,7 +122,7 @@
<navbar <navbar
cmsWidgetName="FunnelFooterWidget" cmsWidgetName="FunnelFooterWidget"
ref="navbar" ref="navbar"
:isForwardActionDisabled="!meta.valid || isForwardActionDisabled || mobileLocationModalOpened" :isForwardActionDisabled="!meta.valid || isForwardActionDisabled"
@back-clicked="backButtonAction" @back-clicked="backButtonAction"
@ForwardClicked="forwardButtonAction" /> @ForwardClicked="forwardButtonAction" />
</div> </div>
@ -177,12 +176,11 @@ const MOBILE_FEE_PART_TYPE = "MOBILE FEE";
// DEFINE VALIDATION RULES // DEFINE VALIDATION RULES
defineRule("mobile-location-required", (value) => { defineRule("mobile-location-required", (value) => {
if ( if (
value.isMobileSelectedAndModalClosed && !value.addressQuestions.streetAddress ||
(!value.addressQuestions.streetAddress || !value.addressQuestions.city ||
!value.addressQuestions.city || !value.addressQuestions.state ||
!value.addressQuestions.state || !value.addressQuestions.zipCode ||
!value.addressQuestions.zipCode || !value.isVehicleProtected
!value.isVehicleProtected)
) { ) {
return errorMessages.MOBILE_LOCATION_REQUIRED; return errorMessages.MOBILE_LOCATION_REQUIRED;
} }
@ -217,7 +215,6 @@ export default {
shopProviderData: null, shopProviderData: null,
navigatingForward: false, navigatingForward: false,
isMobileAddressValid: true, isMobileAddressValid: true,
mobileLocationModalOpened: false,
}; };
}, },
async beforeRouteEnter(to, from, next) { async beforeRouteEnter(to, from, next) {
@ -308,9 +305,6 @@ export default {
zipCode: this.zipCode, zipCode: this.zipCode,
}, },
isVehicleProtected: this.isVehicleProtected, isVehicleProtected: this.isVehicleProtected,
isMobileSelectedAndModalClosed:
this.selectedAppointmentType === "Mobile" &&
!this.mobileLocationModalOpened,
}; };
}, },
}, },
@ -514,9 +508,6 @@ export default {
setRecycleFeePart(recycleFeePart) { setRecycleFeePart(recycleFeePart) {
this.recycleFeePart = recycleFeePart; this.recycleFeePart = recycleFeePart;
}, },
setMobileLocationModalOpened(isModalOpened) {
this.mobileLocationModalOpened = isModalOpened;
},
//creating async function as the computed property can not directly handle asynchronous operations or promises. //creating async function as the computed property can not directly handle asynchronous operations or promises.
async setMobileLocationQuestions(newValue) { async setMobileLocationQuestions(newValue) {
var newZipCode = newValue.addressQuestions.zipCode; var newZipCode = newValue.addressQuestions.zipCode;
@ -784,9 +775,11 @@ export default {
this.selectedProvider = new Provider( this.selectedProvider = new Provider(
this.shopProviderData.mobileProviderNumber this.shopProviderData.mobileProviderNumber
); );
var mobileLocationQs = this.$refs.mobileLocationQuestions; var mobileLocationQuestionsRef = this.$refs.mobileLocationQuestions;
if (!mobileLocationQs.isMobileAddressComplete()) { var isMobileAddressComplete =
mobileLocationQs.openModal(); mobileLocationQuestionsRef.isMobileAddressComplete;
if (isMobileAddressComplete) {
mobileLocationQuestionsRef.isMobileLocationOpened = true;
} }
} else { } else {
this.selectedProvider = new Provider(); this.selectedProvider = new Provider();