This commit is contained in:
Kroell 2023-04-19 14:28:32 -04:00
parent 9d68cd7b7b
commit 9a47c7762c
3 changed files with 34 additions and 33 deletions

View file

@ -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(

View file

@ -12,7 +12,6 @@
<serviceZipModalQuestion
v-model="serviceZipCodeQuestion"
ref="serviceZipCodeQuestion"
linkWidgetName="ServiceZipLinkWidget"
modalWidgetName="ServiceZipModalWidget" />
<buttonQuestion
cmsWidgetName="ServiceTypeQuestionWidget"
@ -76,7 +75,7 @@ export default {
// Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
const serviceZipCode = useMainStore().order.serviceLocation.zipCode;
const serviceZipCode = useMainStore().order.customer.address.zipCode;
const getZipCodeData = baseMixin.methods.getZipCodeData(serviceZipCode);
const serviceabilityDetailsPromise = getServiceabilityDetails(serviceZipCode);
@ -109,8 +108,8 @@ export default {
},
data() {
return {
serviceZip: this.mainStore.order.customer.address.zipCode,
serviceZipState: this.mainStore.order.customer.address.state,
zipCode: this.mainStore.order.customer.address.zipCode,
state: this.mainStore.order.customer.address.state,
isServiceZipServiceable: null,
};
},
@ -124,18 +123,20 @@ export default {
serviceZipCodeQuestion: {
get: function() {
return {
serviceZip: this.serviceZip,
serviceZipState: this.serviceZipState,
zipCode: this.zipCode,
state: this.state,
};
},
set: function (newValue) {
if (newValue.serviceZip !== this.serviceZip) {
//this.resetMobileLocation();
//this.selectedAppointmentType = null;
//this.providerNumber = null;
}
this.serviceZip = newValue.serviceZip;
this.serviceZipState = newValue.serviceZipState;
// if (newValue.zipCode !== this.zipCode) {
// this.resetMobileLocation();
// this.selectedAppointmentType = null;
// this.providerNumber = null;
// }
this.zipCode = newValue.zipCode;
this.state = newValue.state;
this.$nextTick();
},
}
},

View file

@ -19,7 +19,7 @@
<serviceZipQuestion
ref="serviceZipQuestion"
customInputId="serviceZipCode"
v-model="internalModel.serviceZip"
v-model="internalModel.zipCode"
v-on="{ 'textboxQuestionEvent.inputIdAssigned': onInputIdAssigned }"
:cmsWidgetName="textboxQuestionWidgetName" />
<alert
@ -42,7 +42,7 @@ import { getServiceabilityDetails } from "@/helpers/service-location-helper";
export default {
name: "service-zip-modal-question",
emits: ["update:modalValue", "updated-mobile-fee-part", "updated-contains-military-base"],
emits: ["update:modelValue", "updated-contains-military-base"],
data() {
return {
internalModel: this.copyModel(this.modelValue),
@ -54,14 +54,10 @@ export default {
modelValue: {
type: Object,
default: () => ({
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();
},