get/set zip code
This commit is contained in:
parent
05eff89aea
commit
d425b88f38
2 changed files with 38 additions and 31 deletions
|
|
@ -38,10 +38,7 @@ import serviceZipQuestion from "@/layouts/service-location/service-zip-modal-que
|
|||
import modal from "@/digital-components/modal/modal.vue"
|
||||
import alert from "@/ux-components/alert/alert";
|
||||
|
||||
// import {
|
||||
// getPricedMobileFeePart,
|
||||
// getServiceabilityDetails,
|
||||
// } from "@/layouts/service-location/helpers/service-location-helper/service-location-helper";
|
||||
import { getServiceabilityDetails } from "@/helpers/service-location-helper";
|
||||
|
||||
export default {
|
||||
name: "service-zip-modal-question",
|
||||
|
|
@ -128,33 +125,30 @@ export default {
|
|||
this.internalModel.serviceZip = this.modelValue.serviceZip;
|
||||
this.resetsOnZipInput();
|
||||
},
|
||||
// async setZipCode() {
|
||||
// if (this.internalModel.serviceZip !== this.modelValue.serviceZip) {
|
||||
// this.resetAlerts();
|
||||
// const zipCodeData = await this.getZipCodeData(this.internalModel.serviceZip);
|
||||
// if (!zipCodeData.isValid) {
|
||||
// this.displayInvalidZipAlert = true;
|
||||
// this.focusOnZipInput();
|
||||
// this.resetModalButtonStyle();
|
||||
// } else {
|
||||
// this.internalModel.serviceZipState = zipCodeData.serviceZipState;
|
||||
// // retrieve mobile fee part
|
||||
// const serviceZipCode = this.internalModel.serviceZip;
|
||||
// const mobileFeePart = await getPricedMobileFeePart(serviceZipCode);
|
||||
// // retrieve serviceability details
|
||||
// const serviceabilityDetails = await getServiceabilityDetails(serviceZipCode);
|
||||
// // update content related to service zip code
|
||||
// this.$emit("updated-mobile-fee-part", mobileFeePart);
|
||||
// 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();
|
||||
// }
|
||||
// } else {
|
||||
// this.closeModal();
|
||||
// }
|
||||
// },
|
||||
async setZipCode() {
|
||||
if (this.internalModel.serviceZip !== this.modelValue.serviceZip) {
|
||||
this.resetAlerts();
|
||||
const zipCodeData = await this.getZipCodeData(this.internalModel.serviceZip);
|
||||
if (!zipCodeData.isValid) {
|
||||
this.displayInvalidZipAlert = true;
|
||||
this.focusOnZipInput();
|
||||
this.resetModalButtonStyle();
|
||||
} else {
|
||||
this.internalModel.serviceZipState = zipCodeData.serviceZipState;
|
||||
const serviceZipCode = this.internalModel.serviceZip;
|
||||
// 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();
|
||||
}
|
||||
} else {
|
||||
this.closeModal();
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
modelValue(newValue) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,19 @@ export default {
|
|||
savePageDataToStore(page, data) {
|
||||
useMainStore().updatePageData({ page: page, data: data});
|
||||
},
|
||||
async getZipCodeData(zipCode) {
|
||||
const serviceZipValidationResponse = await useMainStore().validateZip(
|
||||
{ zip: zipCode }
|
||||
);
|
||||
|
||||
return {
|
||||
containsMilitaryBase: serviceZipValidationResponse.data.containsMilitaryBase,
|
||||
isValid: serviceZipValidationResponse.data.isValid,
|
||||
isServiceable: serviceZipValidationResponse.data.isServiceable,
|
||||
state: serviceZipValidationResponse.data.state,
|
||||
zipCodeCtu: serviceZipValidationResponse.data.zipCodeCtu,
|
||||
};
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
// store will be accessible globally as its id + 'Store'
|
||||
|
|
|
|||
Loading…
Reference in a new issue