SSR-1727 Fix passing wrong CTU value to the hop
This commit is contained in:
parent
6ef4087b8f
commit
15a088b594
6 changed files with 50 additions and 17 deletions
|
|
@ -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`
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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" />
|
||||
<shopQuestion
|
||||
v-show="isShopQuestionDisplayed"
|
||||
:ref="SHOP_QUESTION_REF_NAME"
|
||||
|
|
@ -468,6 +467,9 @@ export default {
|
|||
getSelectedProvider() {
|
||||
return useMainStore().order.serviceLocation.provider;
|
||||
},
|
||||
setCtuForMobile(val) {
|
||||
this.zipCodeCtu = val;
|
||||
},
|
||||
async setData(
|
||||
zipCodeData,
|
||||
serviceabilityDetails,
|
||||
|
|
|
|||
|
|
@ -2627,6 +2627,24 @@ export const useMainStore = defineStore({
|
|||
}
|
||||
},
|
||||
|
||||
async validateMobileZip({ zip }) {
|
||||
const damageType = this.order.damage.isRepair ? 'Repair' : 'Replace';
|
||||
try {
|
||||
const response = await globalMethods.callHttpClient({
|
||||
method: endpoints.ValidateZip.method,
|
||||
endpoint: endpoints.ValidateMobileZip.url(zip, damageType)
|
||||
});
|
||||
const zipInfo = response.data;
|
||||
if (zipInfo?.isValid === true) {
|
||||
return Promise.resolve(zipInfo);
|
||||
}
|
||||
|
||||
return Promise.reject(new Error('Invalid Zip Info'));
|
||||
} catch (e) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
},
|
||||
|
||||
async getBillToInfo() {
|
||||
const { order, issConfig } = this;
|
||||
try {
|
||||
|
|
@ -2804,6 +2822,7 @@ export const useMainStore = defineStore({
|
|||
this.order.serviceLocation.appointmentType = null;
|
||||
this.order.serviceLocation.IsSafeliteProvider = null;
|
||||
this.resetServiceLocationProvider();
|
||||
this.resetServiceLocationMobileAddress();
|
||||
},
|
||||
|
||||
resetPageFields() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue