From 15a088b59449299ef757f7ab1a9e5cca3183b155 Mon Sep 17 00:00:00 2001 From: Josh Dassinger Date: Fri, 1 Nov 2024 09:58:07 -0500 Subject: [PATCH] SSR-1727 Fix passing wrong CTU value to the hop --- src/constants/endpoints.js | 4 +++ src/helpers/service-location-helper.js | 28 +++++++++++-------- src/layouts/payment-page/payment-page.vue | 2 +- .../mobile-location-modal-questions.vue | 6 ++-- .../service-location/service-location.vue | 8 ++++-- src/store/index.js | 19 +++++++++++++ 6 files changed, 50 insertions(+), 17 deletions(-) diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index a86bc8aa..3750f194 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -181,6 +181,10 @@ const endpoints = Object.freeze({ url: (zip) => `${LOCATION_BASE_URL}/zip/${zip}`, method: 'GET' }, + ValidateMobileZip: { + url: (zip, damage) => `${LOCATION_BASE_URL}/zip/${zip}/${damage}`, + method: 'GET' + }, GooglePlaces: { url: (apiKey) => `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=places` }, diff --git a/src/helpers/service-location-helper.js b/src/helpers/service-location-helper.js index 9f869601..37127226 100644 --- a/src/helpers/service-location-helper.js +++ b/src/helpers/service-location-helper.js @@ -1,17 +1,23 @@ import { useMainStore } from '@/store'; +function processZipCodeResults(request) { + return request.then((serviceZipValidationResponse) => ({ + containsMilitaryBase: serviceZipValidationResponse.containsMilitaryBase, + isValid: serviceZipValidationResponse.isValid, + isServiceable: serviceZipValidationResponse.isServiceable, + state: serviceZipValidationResponse.state, + zipCodeCtu: serviceZipValidationResponse.zipCodeCtu + })).catch(() => ({ + isValid: false + })); +} + export async function getZipCodeData(zipCode) { - return await useMainStore().validateZip({ zip: zipCode }) - .then((serviceZipValidationResponse) => ({ - containsMilitaryBase: serviceZipValidationResponse.containsMilitaryBase, - isValid: serviceZipValidationResponse.isValid, - isServiceable: serviceZipValidationResponse.isServiceable, - state: serviceZipValidationResponse.state, - zipCodeCtu: serviceZipValidationResponse.zipCodeCtu - })) - .catch(() => ({ - isValid: false - })); + return await processZipCodeResults(useMainStore().validateZip({ zip: zipCode })); +} + +export async function getMobileZipCodeData(zipCode) { + return await processZipCodeResults(useMainStore().validateMobileZip({ zip: zipCode })); } export async function getPricedMobileFeePart(serviceZipCode) { diff --git a/src/layouts/payment-page/payment-page.vue b/src/layouts/payment-page/payment-page.vue index 052f2c24..c709ae39 100644 --- a/src/layouts/payment-page/payment-page.vue +++ b/src/layouts/payment-page/payment-page.vue @@ -488,7 +488,7 @@ export default { firstName: useMainStore().order.contactInfo.firstName, lastName: useMainStore().order.contactInfo.lastName, phoneNumber: useMainStore().order.contactInfo.servicePhone, - ctu: useMainStore().order.serviceLocation.zipCodeCtu, + ctu: useMainStore().order.serviceLocation.provider?.address?.zipCodeCtu ?? useMainStore().order.serviceLocation.zipCodeCtu, referralCorrelationId: useMainStore().order.referralCorrelationId, workOrderNumber: this.getWorkOrderNumber(), invoiceNumber: this.getInvoiceNumber(), diff --git a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue index 13d28873..dd6df70d 100644 --- a/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue +++ b/src/layouts/service-location/mobile-location-modal-questions/mobile-location-modal-questions.vue @@ -88,6 +88,7 @@ import { experimentSettings } from '@/constants/experiments'; // Helpers import { useMainStore } from '@/store'; import { + getMobileZipCodeData, getPricedMobileFeePart, getServiceabilityDetails, getZipCodeData @@ -132,7 +133,7 @@ export default { type: Function } }, - emits: ['update:modelValue', 'updated-mobile-fee-part', 'updated-contains-military-base', 'updated-serviceability'], + emits: ['update:modelValue', 'updated-mobile-fee-part', 'updated-contains-military-base', 'updated-serviceability', 'updated-mobile-ctu'], setup(props) { const uuid = crypto.randomUUID(); const componentId = !props.customComponentId @@ -268,7 +269,7 @@ export default { !== this.modelValue.addressQuestions.zipCode ) { // Validate the Zip Code - const zipCodeData = await getZipCodeData(this.internalModel.addressQuestions.zipCode); + const zipCodeData = await getMobileZipCodeData(this.internalModel.addressQuestions.zipCode); if (!zipCodeData.isValid) { this.displayInvalidZipAlert = true; @@ -284,6 +285,7 @@ export default { // update content related to service zip code this.$emit('updated-mobile-fee-part', mobileFeePart); this.$emit('updated-serviceability', serviceabilityDetails.data); + this.$emit('updated-mobile-ctu', zipCodeData.zipCodeCtu); this.$emit('updated-contains-military-base', zipCodeData.containsMilitaryBase); if (this.onZipUpdateCallback) { diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index 09772447..0d25700b 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -81,9 +81,8 @@ :onZipUpdateCallback="reloadShopData" @updated-mobile-fee-part="setMobileFeePart" @updated-serviceability="setServiceabilityDetails" - @updated-contains-military-base=" - setContainsMilitaryBase - " /> + @updated-contains-military-base="setContainsMilitaryBase" + @updated-mobile-ctu="setCtuForMobile" />