From 09ed0819ff69d1a39a47324545a24f9100efd654 Mon Sep 17 00:00:00 2001 From: Kroell Date: Mon, 17 Apr 2023 16:16:00 -0400 Subject: [PATCH] WIP --- src/helpers/service-location-helper.js | 44 +++++++++++++++++++ .../service-zip-modal-question.vue | 38 +++++++++++++++- 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 src/helpers/service-location-helper.js diff --git a/src/helpers/service-location-helper.js b/src/helpers/service-location-helper.js new file mode 100644 index 00000000..62b0f6db --- /dev/null +++ b/src/helpers/service-location-helper.js @@ -0,0 +1,44 @@ +import { useMainStore } from '@/store'; +import baseMixin from "@/mixins/base-mixin.js"; + +export async function getPricedMobileFeePart(serviceZipCode) { + if (!serviceZipCode) { + return Promise.resolve(null); + } + + const zipCodeData = await baseMixin.methods.getZipCodeData(serviceZipCode); + + // Get the Mobile Fee Part + const mobileFeePart = await baseMixin.methods.dispatchStoreAction( + useMainStore.GET_MOBILE_FEE_PART, + null, + false + ); + + // Get the Mobile Fee Part Price + const pricingResults = await baseMixin.methods.dispatchStoreAction( + useMainStore.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA, + { + availableLineItems: [mobileFeePart.data], + serviceZipCode: serviceZipCode, + serviceZipCodeCtu: zipCodeData.zipCodeCtu, + }, + false + ); + + return Promise.resolve(pricingResults[0]); +} + +export async function getServiceabilityDetails(serviceZipCode, lineItems) { + // Get the Mobile Fee Part + const serviceabilityDetails = await baseMixin.methods.dispatchStoreAction( + useMainStore.GET_SERVICEABILITY_DETAILS, + { + serviceZipCode: serviceZipCode, + lineItems: lineItems, + }, + false + ); + + return Promise.resolve(serviceabilityDetails); +} \ No newline at end of file diff --git a/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue b/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue index 78a50011..16491057 100644 --- a/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue +++ b/src/layouts/service-location/service-zip-modal-question/service-zip-modal-question.vue @@ -38,9 +38,14 @@ 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"; + export default { name: "service-zip-modal-question", - emits: ["update:modalValue"], + emits: ["update:modalValue", "updated-mobile-fee-part", "updated-contains-military-base"], data() { return { internalModel: this.copyModel(this.modelValue), @@ -56,6 +61,10 @@ export default { serviceZipState: "", }) }, + mobileFeePart: { + type: Object, + default: () => ({}), + }, modalWidgetName: String, }, setup() { @@ -119,6 +128,33 @@ 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(); + // } + // }, }, watch: { modelValue(newValue) {