Updates for glass-fees call

This commit is contained in:
Bill Richardson 2024-10-10 11:32:53 -04:00
parent a4f1126acf
commit 68ae6e0498
5 changed files with 105 additions and 35 deletions

View file

@ -117,6 +117,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'

View file

@ -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}`

View file

@ -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;
},

View file

@ -115,7 +115,9 @@
<script>
// Import Supporting Files
import { AppointmentTypeStrings } from '@/constants/schedule-constants.js';
import bailoutMessage from '@/constants/bailoutMessage';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
import settleAllPromises from '@/helpers/layout-helper';
import { required } from '@/helpers/validation-rules';
import errorMessages from '@/constants/error-messages';
@ -177,17 +179,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 +196,10 @@ export default {
resultKey: 'mobileFeePart',
promise: mobileFeePartPromise
},
{
resultKey: 'glassFees',
promise: getGlassFeesPromise
},
{
resultKey: 'serviceabilityDetails',
promise: serviceabilityDetailsPromise
@ -215,13 +216,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 +310,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 +393,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 +470,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 +493,40 @@ export default {
if (mobileProviderNumber) {
this.setMobileProviderNumber(mobileProviderNumber);
}
if (glassFees) {
// We only call the ITAC pricing endpoint if we are not repair or we are NoComp
if (!this.isRepair || this.mainStore.isNoComp) {
const { glassParts } = this.mainStore.order.lineItems;
const availableLineItems = [
...(glassParts ?? []), // if only glassFee and price is 0.00 tosses a 500 so including parts
...(glassFees ?? [])
];
await useMainStore().getITACPriceOrderItems(availableLineItems)
.catch((err) => {
useMainStore().setBailout(bailoutMessage.pricingResponseError(
availableLineItems.map((li) => li.partNumber),
{
code: err.code,
message: err.message,
data: err.data
}
));
this.navigateWithScenario(navigationScenarios.PRICING_LOOKUP_ERROR);
});
this.setGlassFeeItems(glassFees);
}
}
},
setContainsMilitaryBase(val) {
if (this.zipContainsMilitaryBase !== val) {
this.zipContainsMilitaryBase = val;
}
},
setGlassFeeItems(newGlassFeeItems) {
this.mainStore.updateGlassFees(newGlassFeeItems);
},
setMobileFeePart(mobileFeePart) {
this.mobileFeePart = mobileFeePart;
},

View file

@ -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,42 @@ export const useMainStore = defineStore({
}
}
},
async getGlassFees() {
const { insuranceCoverage } = this.order;
const { glassParts } = this.lineItems;
const { carId } = this.vehicle;
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 queryString =
`ServiceType=${damageType}`
+ `&FacilityType=${facilityType}`
+ `&ParentAccountNumber=${this.order.parentAccountNumber}`
+ `&BillToAccountNumber=${this.billToAccountNumber}`
+ `&IsPremiumAppointment=${false}`
+ `&IsItacOptimized=${false}`
+ `&ZipCode=${zipCode}`
+ `&CoverageStatus=${coverageStatuses.mapToApi(insuranceCoverage.coverageStatus)}`
+ `&CoverageType=${coverageType.mapToApi(insuranceCoverage.coverageType)}`
+ `&ProviderNumber=${providerToUse}`
+ `&CarId=${carId}`
+ `${partNumberListQueryString}`;
return globalMethods
.callHttpClient({
method: endpoints.GetGlassFees.method,
endpoint: `${endpoints.GetGlassFees.url}?${queryString}`
});
},
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,
@ -1831,7 +1865,15 @@ 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;
}
// Process Recycle Fee
this.updateRecycleFee(feeData.find((rf) => rf.partNumber === partNumberStrings.RECYCLE_FEE));
},
updateSupportingItems(partsData) {
if (partsData == null) {
this.order.lineItems.supportingItems = null;