diff --git a/src/helpers/service-location-helper.js b/src/helpers/service-location-helper.js index ca8841c8..da98fb33 100644 --- a/src/helpers/service-location-helper.js +++ b/src/helpers/service-location-helper.js @@ -1,5 +1,4 @@ import { useMainStore } from '@/store'; -import baseMixin from "@/mixins/base-mixin.js"; export async function getServiceabilityDetails(serviceZipCode, lineItems) { const serviceabilityDetails = await useMainStore().getServiceabilityDetails( diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 0021735a..28151758 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -12,7 +12,6 @@ ({ - serviceZip: "", - serviceZipState: "", + state: "", + zipCode: "", }) }, - mobileFeePart: { - type: Object, - default: () => ({}), - }, modalWidgetName: String, }, setup() { @@ -74,8 +70,8 @@ export default { }, computed: { serviceZipLinkText() { - if (this.modelValue.serviceZip && this.modelValue.serviceZip.length > 0) { - return this.modelValue.serviceZipState + ", " + this.modelValue.serviceZip; + if (this.modelValue.zipCode && this.modelValue.zipCode.length > 0) { + return this.modelValue.state + ", " + this.modelValue.zipCode; } }, modalHeaderText() { @@ -101,8 +97,8 @@ export default { }, copyModel(modelToCopy) { return { - serviceZipState: modelToCopy.serviceZipState, - serviceZip: modelToCopy.serviceZip, + state: modelToCopy.state, + zipCode: modelToCopy.zipCode, }; }, openModal() { @@ -118,29 +114,34 @@ export default { this.serviceZipCodeTextInputId = inputId; }, onModalOpened() { - this.internalModel.serviceZip = this.modelValue.serviceZip; + this.internalModel.zipCode = this.modelValue.zipCode; this.focusOnZipInput(); }, onModalClosed() { - this.internalModel.serviceZip = this.modelValue.serviceZip; + this.internalModel.zipCode = this.modelValue.zipCode; this.resetsOnZipInput(); }, async setZipCode() { - if (this.internalModel.serviceZip !== this.modelValue.serviceZip) { + if (this.internalModel.zipCode !== this.modelValue.zipCode) { this.resetAlerts(); - const zipCodeData = await this.getZipCodeData(this.internalModel.serviceZip); + + const zipCodeData = await this.getZipCodeData(this.internalModel.zipCode); + if (!zipCodeData.isValid) { this.displayInvalidZipAlert = true; this.focusOnZipInput(); this.resetModalButtonStyle(); } else { - this.internalModel.serviceZipState = zipCodeData.state; - const serviceZipCode = this.internalModel.serviceZip; + this.internalModel.state = zipCodeData.state; + const serviceZipCode = this.internalModel.zipCode; + // retrieve serviceability details const serviceabilityDetails = await getServiceabilityDetails(serviceZipCode); + // update content related to service zip code this.$emit("updated-serviceability", serviceabilityDetails.data); this.$emit("updated-contains-military-base", zipCodeData.containsMilitaryBase); + // Update the page level model this.$emit("update:modelValue", this.internalModel); this.closeModal(); @@ -154,7 +155,7 @@ export default { modelValue(newValue) { this.internalModel = this.copyModel(newValue); }, - "internalModel.serviceZip": { + "internalModel.zipCode": { handler() { this.resetsOnZipInput(); },