Merge pull request #857 from Safelite/feature/richardson/SSR-1518
Updates for glass-fees call
This commit is contained in:
commit
14f7d50630
5 changed files with 88 additions and 79 deletions
|
|
@ -72,10 +72,6 @@ const endpoints = Object.freeze({
|
|||
url: `${PARTS_BASE_URL}/parts`,
|
||||
method: 'POST'
|
||||
},
|
||||
GetInsurancePriceOrderItems: {
|
||||
url: `${PRICE_BASE_URL}/order-items-with-insurance-pricing`,
|
||||
method: 'GET'
|
||||
},
|
||||
GetITACPriceOrderItems: {
|
||||
url: `${PRICE_BASE_URL}/order-items-with-itac-pricing`,
|
||||
method: 'POST'
|
||||
|
|
@ -117,6 +113,10 @@ const endpoints = Object.freeze({
|
|||
) => `${PARTS_BASE_URL}/recal-parts/${carId}/${partNumber}/${recalibrationType}/${parentAccountNumber}/${zipCode}/${applicationName}/${referralSequenceNumber}`,
|
||||
method: 'GET'
|
||||
},
|
||||
GetGlassFees: {
|
||||
url: `${PARTS_BASE_URL}/glass-fees`,
|
||||
method: 'GET'
|
||||
},
|
||||
GetSupportingItems: {
|
||||
url: `${PARTS_BASE_URL}/supporting-items`,
|
||||
method: 'POST'
|
||||
|
|
|
|||
|
|
@ -29,6 +29,12 @@ export function getLineItemQueryString(lineItems, parameterName) {
|
|||
return queryString.length !== 0 ? `&${queryString}` : '';
|
||||
}
|
||||
|
||||
export function getPartNumbersListForQueryString(lineItems, parameterName) {
|
||||
const queryString = getLineItemsFlattened(lineItems).map((lineItem) =>
|
||||
`${parameterName}=${lineItem.partNumber}`).join('&');
|
||||
return queryString.length !== 0 ? `&${queryString}` : '';
|
||||
}
|
||||
|
||||
export function getTaxLineItemQueryString(lineItems, parameterName) {
|
||||
const queryString = getLineItemsFlattened(lineItems).map((lineItem, index) =>
|
||||
`${parameterName}[${index}].partNumber=${lineItem.partNumber}`
|
||||
|
|
|
|||
|
|
@ -158,7 +158,6 @@ export default {
|
|||
|
||||
// Call APIs
|
||||
const cmsContentPromise = fetchCmsContentForPage(to?.query?.issPage);
|
||||
const supportingItemsPromise = store.getSupportingItems();
|
||||
const getRecalPartsPromise = store.getRecalParts();
|
||||
|
||||
// Settle promises and get results
|
||||
|
|
@ -167,10 +166,6 @@ export default {
|
|||
resultKey: 'cmsContent',
|
||||
promise: cmsContentPromise
|
||||
},
|
||||
{
|
||||
resultKey: 'supportingItems',
|
||||
promise: supportingItemsPromise
|
||||
},
|
||||
{
|
||||
resultKey: 'recalParts',
|
||||
promise: getRecalPartsPromise
|
||||
|
|
@ -197,7 +192,6 @@ export default {
|
|||
next(async (vm) => {
|
||||
showIssLoadingModal(true);
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
vm.setSupportingItems(resultMap.supportingItems);
|
||||
await vm.initializeComponent();
|
||||
if (!vm.unverified) {
|
||||
useMainStore().disableKeyFields();
|
||||
|
|
@ -401,10 +395,9 @@ export default {
|
|||
showIssLoadingModal(false);
|
||||
},
|
||||
async getPricedParts() {
|
||||
const { glassParts, supportingItems } = this.mainStore.order.lineItems;
|
||||
const { glassParts } = this.mainStore.order.lineItems;
|
||||
const availableLineItems = [
|
||||
...(glassParts ?? []),
|
||||
...(supportingItems ?? [])
|
||||
...(glassParts ?? [])
|
||||
];
|
||||
|
||||
// We only call the ITAC pricing endpoint if we are not repair or we are NoComp
|
||||
|
|
@ -480,9 +473,6 @@ export default {
|
|||
return null;
|
||||
}
|
||||
},
|
||||
setSupportingItems(newSupportingItems) {
|
||||
this.mainStore.updateSupportingItems(newSupportingItems);
|
||||
},
|
||||
setBaseServiceLineItems(lineItems) {
|
||||
this.baseServiceLineItems = lineItems;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -177,17 +177,12 @@ export default {
|
|||
async beforeRouteEnter(to, from, next) {
|
||||
// Call APIs
|
||||
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
|
||||
|
||||
const serviceZipCode =
|
||||
useMainStore().order.serviceLocation.zipCode
|
||||
|| useMainStore().order.customer.address.zipCode;
|
||||
const serviceZipCode = useMainStore().order.serviceLocation.zipCode || useMainStore().order.customer.address.zipCode;
|
||||
const zipCodeData = getZipCodeData(serviceZipCode);
|
||||
|
||||
const mobileFeePartPromise = getPricedMobileFeePart(serviceZipCode);
|
||||
const serviceabilityDetailsPromise =
|
||||
getServiceabilityDetails(serviceZipCode);
|
||||
const shopQuestionInitialDataPromise =
|
||||
shopQuestion.methods.loadInitialData(serviceZipCode);
|
||||
const serviceabilityDetailsPromise = getServiceabilityDetails(serviceZipCode);
|
||||
const shopQuestionInitialDataPromise = shopQuestion.methods.loadInitialData(serviceZipCode);
|
||||
const getGlassFeesPromise = useMainStore().getGlassFees();
|
||||
|
||||
// Settle promises and get results
|
||||
const promiseResultMap = [
|
||||
|
|
@ -199,6 +194,10 @@ export default {
|
|||
resultKey: 'mobileFeePart',
|
||||
promise: mobileFeePartPromise
|
||||
},
|
||||
{
|
||||
resultKey: 'glassFees',
|
||||
promise: getGlassFeesPromise
|
||||
},
|
||||
{
|
||||
resultKey: 'serviceabilityDetails',
|
||||
promise: serviceabilityDetailsPromise
|
||||
|
|
@ -215,13 +214,14 @@ export default {
|
|||
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
useMainStore().updateIsSafeliteProvider(true);
|
||||
next((vm) => {
|
||||
next(async (vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
vm.setData(
|
||||
await vm.setData(
|
||||
resultMap.zipCodeData,
|
||||
resultMap.serviceabilityDetails,
|
||||
resultMap.mobileFeePart,
|
||||
resultMap.shopQuestionInitialData?.mobileProviderNumber
|
||||
resultMap.shopQuestionInitialData?.mobileProviderNumber,
|
||||
resultMap.glassFees
|
||||
);
|
||||
vm.$refs[SHOP_QUESTION_REF_NAME].initializeComponent(resultMap.shopQuestionInitialData);
|
||||
});
|
||||
|
|
@ -308,10 +308,8 @@ export default {
|
|||
if (newValue.zipCode !== this.zipCode) {
|
||||
if (
|
||||
!(
|
||||
this.selectedAppointmentType
|
||||
=== AppointmentTypeStrings.MOBILE
|
||||
|| this.selectedAppointmentType
|
||||
=== AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP
|
||||
this.selectedAppointmentType === AppointmentTypeStrings.MOBILE
|
||||
|| this.selectedAppointmentType === AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP
|
||||
)
|
||||
) {
|
||||
this.selectedAppointmentType = null;
|
||||
|
|
@ -393,8 +391,7 @@ export default {
|
|||
methods: {
|
||||
arePagePrerequisitesValid() {
|
||||
return (
|
||||
useMainStore().lineItems.supportingItems !== null
|
||||
&& useMainStore().order.serviceLocation.zipCode !== null
|
||||
useMainStore().order.serviceLocation.zipCode !== null
|
||||
);
|
||||
},
|
||||
async reloadShopData(zipCode) {
|
||||
|
|
@ -471,11 +468,12 @@ export default {
|
|||
getSelectedProvider() {
|
||||
return useMainStore().order.serviceLocation.provider;
|
||||
},
|
||||
setData(
|
||||
async setData(
|
||||
zipCodeData,
|
||||
serviceabilityDetails,
|
||||
mobileFeePart,
|
||||
mobileProviderNumber
|
||||
mobileProviderNumber,
|
||||
glassFees
|
||||
) {
|
||||
if (zipCodeData) {
|
||||
this.zipContainsMilitaryBase = zipCodeData.containsMilitaryBase;
|
||||
|
|
@ -493,12 +491,20 @@ export default {
|
|||
if (mobileProviderNumber) {
|
||||
this.setMobileProviderNumber(mobileProviderNumber);
|
||||
}
|
||||
|
||||
if (glassFees) {
|
||||
const pricedGlassFees = await useMainStore().getCombinedQuote(glassFees);
|
||||
this.setGlassFeeItems(pricedGlassFees);
|
||||
}
|
||||
},
|
||||
setContainsMilitaryBase(val) {
|
||||
if (this.zipContainsMilitaryBase !== val) {
|
||||
this.zipContainsMilitaryBase = val;
|
||||
}
|
||||
},
|
||||
setGlassFeeItems(newGlassFeeItems) {
|
||||
this.mainStore.updateGlassFees(newGlassFeeItems);
|
||||
},
|
||||
setMobileFeePart(mobileFeePart) {
|
||||
this.mobileFeePart = mobileFeePart;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -25,7 +25,12 @@ import bailoutMessage from '@/constants/bailoutMessage';
|
|||
import bailoutCode from '@/constants/bailoutCode';
|
||||
import partNumberStrings from '@/constants/part-number-strings';
|
||||
import { findLineItemIndex, getLineItemsFlattened } from '@/helpers/line-items-helper';
|
||||
import { buildQueryStringParameterFromArrayOfComplexObjects, getLineItemQueryString, getTaxLineItemQueryString } from '@/helpers/querystring-helper';
|
||||
import {
|
||||
buildQueryStringParameterFromArrayOfComplexObjects,
|
||||
getLineItemQueryString,
|
||||
getPartNumbersListForQueryString,
|
||||
getTaxLineItemQueryString
|
||||
} from '@/helpers/querystring-helper';
|
||||
import coverageType from '@/constants/coverage-type';
|
||||
import { getExperimentSettingValue, getFeatureTogglesQueryString } from '@/helpers/experiment-helper';
|
||||
import { getSessionKeyValue, getUserIdValue, deleteISSCookie } from '@/helpers/cookie-helper';
|
||||
|
|
@ -1071,13 +1076,40 @@ export const useMainStore = defineStore({
|
|||
}
|
||||
}
|
||||
},
|
||||
async getGlassFees() {
|
||||
const { insuranceCoverage, vehicle } = this.order;
|
||||
const { glassParts } = this.lineItems;
|
||||
const { isRepair } = this.damage;
|
||||
const { defaultProviderNumber, provider, zipCode } = this.order.serviceLocation;
|
||||
const damageType = isRepair ? 'Repair' : 'Install';
|
||||
const facilityType = this.isMobileAppointment ? 'Mobile' : 'InShop';
|
||||
const providerToUse = provider?.providerNumber ?? defaultProviderNumber;
|
||||
const partNumberListQueryString = getPartNumbersListForQueryString(glassParts, 'PartNumbers');
|
||||
|
||||
const params = new URLSearchParams({
|
||||
serviceType: damageType,
|
||||
facilityType,
|
||||
parentAccountNumber: this.order.parentAccountNumber,
|
||||
billToAccountNumber: this.billToAccountNumber,
|
||||
isPremiumAppointment: false,
|
||||
isItacOptimized: insuranceCoverage.isItacOptimized,
|
||||
zipCode,
|
||||
coverageStatus: coverageStatuses.mapToApi(insuranceCoverage.coverageStatus),
|
||||
coverageType: coverageType.mapToApi(insuranceCoverage.coverageType),
|
||||
providerNumber: providerToUse,
|
||||
carId: vehicle.carId
|
||||
});
|
||||
|
||||
return globalMethods.callHttpClient({
|
||||
method: endpoints.GetGlassFees.method,
|
||||
endpoint: `${endpoints.GetGlassFees.url}?${params.toString()}${partNumberListQueryString}`
|
||||
});
|
||||
},
|
||||
async getSupportingItems() {
|
||||
const { glassParts } = this.lineItems;
|
||||
const { carId } = this.vehicle;
|
||||
const { isRepair, numberOfChips } = this.damage;
|
||||
|
||||
console.log('supporting http response..');
|
||||
|
||||
return globalMethods
|
||||
.callHttpClient({
|
||||
method: endpoints.GetSupportingItems.method,
|
||||
|
|
@ -1092,46 +1124,6 @@ export const useMainStore = defineStore({
|
|||
});
|
||||
},
|
||||
|
||||
async getInsurancePriceOrderItems(availableLineItems) {
|
||||
const { serviceLocation, currentDeductible } = this.order;
|
||||
const lineItemsQueryString = getLineItemQueryString(availableLineItems, 'lineItems');
|
||||
const featureTogglesQueryString = getFeatureTogglesQueryString(this.experimentSettings);
|
||||
|
||||
let queryString =
|
||||
`ParentAccountNumber=${this.order.parentAccountNumber}`
|
||||
+ `&BillToAccountNumber=${this.billToAccountNumber}`
|
||||
+ `&CTU=${serviceLocation.zipCodeCtu}`
|
||||
+ `&Deductible=${currentDeductible ?? 0}`
|
||||
+ `&ZipCode=${serviceLocation.zipCode}`
|
||||
+ `&${featureTogglesQueryString}`
|
||||
+ `${lineItemsQueryString}`;
|
||||
|
||||
const lineItemServerData = this.order.lineItems?.serverData;
|
||||
if (lineItemServerData) {
|
||||
queryString += `&ServerData=${encodeURIComponent(lineItemServerData)}`;
|
||||
}
|
||||
|
||||
const response = await globalMethods
|
||||
.callHttpClient({
|
||||
method: endpoints.GetInsurancePriceOrderItems.method,
|
||||
endpoint: `${endpoints.GetInsurancePriceOrderItems.url}?${queryString}`
|
||||
}).catch((error) => {
|
||||
console.error(error);
|
||||
throw error;
|
||||
});
|
||||
|
||||
const { lineItems, serverData } = response.data;
|
||||
if (serverData) {
|
||||
this.order.lineItems.serverData = serverData;
|
||||
}
|
||||
|
||||
if (lineItems) {
|
||||
const retAvailableLineItems = addPricesToLineItems(availableLineItems, lineItems);
|
||||
return retAvailableLineItems;
|
||||
}
|
||||
return availableLineItems;
|
||||
},
|
||||
|
||||
async getITACPriceOrderItems(availableLineItems) {
|
||||
const { policy, vehicle, contactInfo, serviceLocation, insuranceCoverage } = this.order;
|
||||
const response = await globalMethods
|
||||
|
|
@ -1831,7 +1823,22 @@ export const useMainStore = defineStore({
|
|||
this.order.insuranceCoverage.isItacOptimized = false;
|
||||
this.order.insuranceCoverage.claimNumber = null;
|
||||
},
|
||||
updateGlassFees(feeData) {
|
||||
if (feeData == null) {
|
||||
this.order.lineItems.feeItems = null;
|
||||
return;
|
||||
}
|
||||
|
||||
feeData.forEach((fee) => {
|
||||
if (fee.partNumber === partTypeStrings.MOBILE_FEE) {
|
||||
this.updateMobileFee(fee);
|
||||
} else if (fee.partNumber === partTypeStrings.RECYCLE_FEE) {
|
||||
this.updateRecycleFee(fee);
|
||||
} else {
|
||||
this.addPartNumberFeeItem(fee, fee.partNumber);
|
||||
}
|
||||
});
|
||||
},
|
||||
updateSupportingItems(partsData) {
|
||||
if (partsData == null) {
|
||||
this.order.lineItems.supportingItems = null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue