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}`,
|
url: (zip) => `${LOCATION_BASE_URL}/zip/${zip}`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
|
ValidateMobileZip: {
|
||||||
|
url: (zip, damage) => `${LOCATION_BASE_URL}/zip/${zip}/${damage}`,
|
||||||
|
method: 'GET'
|
||||||
|
},
|
||||||
GooglePlaces: {
|
GooglePlaces: {
|
||||||
url: (apiKey) => `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=places`
|
url: (apiKey) => `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=places`
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,23 @@
|
||||||
import { useMainStore } from '@/store';
|
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) {
|
export async function getZipCodeData(zipCode) {
|
||||||
return await useMainStore().validateZip({ zip: zipCode })
|
return await processZipCodeResults(useMainStore().validateZip({ zip: zipCode }));
|
||||||
.then((serviceZipValidationResponse) => ({
|
}
|
||||||
containsMilitaryBase: serviceZipValidationResponse.containsMilitaryBase,
|
|
||||||
isValid: serviceZipValidationResponse.isValid,
|
export async function getMobileZipCodeData(zipCode) {
|
||||||
isServiceable: serviceZipValidationResponse.isServiceable,
|
return await processZipCodeResults(useMainStore().validateMobileZip({ zip: zipCode }));
|
||||||
state: serviceZipValidationResponse.state,
|
|
||||||
zipCodeCtu: serviceZipValidationResponse.zipCodeCtu
|
|
||||||
}))
|
|
||||||
.catch(() => ({
|
|
||||||
isValid: false
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getPricedMobileFeePart(serviceZipCode) {
|
export async function getPricedMobileFeePart(serviceZipCode) {
|
||||||
|
|
|
||||||
|
|
@ -488,7 +488,7 @@ export default {
|
||||||
firstName: useMainStore().order.contactInfo.firstName,
|
firstName: useMainStore().order.contactInfo.firstName,
|
||||||
lastName: useMainStore().order.contactInfo.lastName,
|
lastName: useMainStore().order.contactInfo.lastName,
|
||||||
phoneNumber: useMainStore().order.contactInfo.servicePhone,
|
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,
|
referralCorrelationId: useMainStore().order.referralCorrelationId,
|
||||||
workOrderNumber: this.getWorkOrderNumber(),
|
workOrderNumber: this.getWorkOrderNumber(),
|
||||||
invoiceNumber: this.getInvoiceNumber(),
|
invoiceNumber: this.getInvoiceNumber(),
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ import { experimentSettings } from '@/constants/experiments';
|
||||||
// Helpers
|
// Helpers
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore } from '@/store';
|
||||||
import {
|
import {
|
||||||
|
getMobileZipCodeData,
|
||||||
getPricedMobileFeePart,
|
getPricedMobileFeePart,
|
||||||
getServiceabilityDetails,
|
getServiceabilityDetails,
|
||||||
getZipCodeData
|
getZipCodeData
|
||||||
|
|
@ -132,7 +133,7 @@ export default {
|
||||||
type: Function
|
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) {
|
setup(props) {
|
||||||
const uuid = crypto.randomUUID();
|
const uuid = crypto.randomUUID();
|
||||||
const componentId = !props.customComponentId
|
const componentId = !props.customComponentId
|
||||||
|
|
@ -268,7 +269,7 @@ export default {
|
||||||
!== this.modelValue.addressQuestions.zipCode
|
!== this.modelValue.addressQuestions.zipCode
|
||||||
) {
|
) {
|
||||||
// Validate the Zip Code
|
// Validate the Zip Code
|
||||||
const zipCodeData = await getZipCodeData(this.internalModel.addressQuestions.zipCode);
|
const zipCodeData = await getMobileZipCodeData(this.internalModel.addressQuestions.zipCode);
|
||||||
|
|
||||||
if (!zipCodeData.isValid) {
|
if (!zipCodeData.isValid) {
|
||||||
this.displayInvalidZipAlert = true;
|
this.displayInvalidZipAlert = true;
|
||||||
|
|
@ -284,6 +285,7 @@ export default {
|
||||||
// update content related to service zip code
|
// update content related to service zip code
|
||||||
this.$emit('updated-mobile-fee-part', mobileFeePart);
|
this.$emit('updated-mobile-fee-part', mobileFeePart);
|
||||||
this.$emit('updated-serviceability', serviceabilityDetails.data);
|
this.$emit('updated-serviceability', serviceabilityDetails.data);
|
||||||
|
this.$emit('updated-mobile-ctu', zipCodeData.zipCodeCtu);
|
||||||
this.$emit('updated-contains-military-base', zipCodeData.containsMilitaryBase);
|
this.$emit('updated-contains-military-base', zipCodeData.containsMilitaryBase);
|
||||||
|
|
||||||
if (this.onZipUpdateCallback) {
|
if (this.onZipUpdateCallback) {
|
||||||
|
|
|
||||||
|
|
@ -81,9 +81,8 @@
|
||||||
:onZipUpdateCallback="reloadShopData"
|
:onZipUpdateCallback="reloadShopData"
|
||||||
@updated-mobile-fee-part="setMobileFeePart"
|
@updated-mobile-fee-part="setMobileFeePart"
|
||||||
@updated-serviceability="setServiceabilityDetails"
|
@updated-serviceability="setServiceabilityDetails"
|
||||||
@updated-contains-military-base="
|
@updated-contains-military-base="setContainsMilitaryBase"
|
||||||
setContainsMilitaryBase
|
@updated-mobile-ctu="setCtuForMobile" />
|
||||||
" />
|
|
||||||
<shopQuestion
|
<shopQuestion
|
||||||
v-show="isShopQuestionDisplayed"
|
v-show="isShopQuestionDisplayed"
|
||||||
:ref="SHOP_QUESTION_REF_NAME"
|
:ref="SHOP_QUESTION_REF_NAME"
|
||||||
|
|
@ -468,6 +467,9 @@ export default {
|
||||||
getSelectedProvider() {
|
getSelectedProvider() {
|
||||||
return useMainStore().order.serviceLocation.provider;
|
return useMainStore().order.serviceLocation.provider;
|
||||||
},
|
},
|
||||||
|
setCtuForMobile(val) {
|
||||||
|
this.zipCodeCtu = val;
|
||||||
|
},
|
||||||
async setData(
|
async setData(
|
||||||
zipCodeData,
|
zipCodeData,
|
||||||
serviceabilityDetails,
|
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() {
|
async getBillToInfo() {
|
||||||
const { order, issConfig } = this;
|
const { order, issConfig } = this;
|
||||||
try {
|
try {
|
||||||
|
|
@ -2804,6 +2822,7 @@ export const useMainStore = defineStore({
|
||||||
this.order.serviceLocation.appointmentType = null;
|
this.order.serviceLocation.appointmentType = null;
|
||||||
this.order.serviceLocation.IsSafeliteProvider = null;
|
this.order.serviceLocation.IsSafeliteProvider = null;
|
||||||
this.resetServiceLocationProvider();
|
this.resetServiceLocationProvider();
|
||||||
|
this.resetServiceLocationMobileAddress();
|
||||||
},
|
},
|
||||||
|
|
||||||
resetPageFields() {
|
resetPageFields() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue