Updates for glass-fees call
This commit is contained in:
parent
a4f1126acf
commit
68ae6e0498
5 changed files with 105 additions and 35 deletions
|
|
@ -117,6 +117,10 @@ const endpoints = Object.freeze({
|
||||||
) => `${PARTS_BASE_URL}/recal-parts/${carId}/${partNumber}/${recalibrationType}/${parentAccountNumber}/${zipCode}/${applicationName}/${referralSequenceNumber}`,
|
) => `${PARTS_BASE_URL}/recal-parts/${carId}/${partNumber}/${recalibrationType}/${parentAccountNumber}/${zipCode}/${applicationName}/${referralSequenceNumber}`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
},
|
},
|
||||||
|
GetGlassFees: {
|
||||||
|
url: `${PARTS_BASE_URL}/glass-fees`,
|
||||||
|
method: 'GET'
|
||||||
|
},
|
||||||
GetSupportingItems: {
|
GetSupportingItems: {
|
||||||
url: `${PARTS_BASE_URL}/supporting-items`,
|
url: `${PARTS_BASE_URL}/supporting-items`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,12 @@ export function getLineItemQueryString(lineItems, parameterName) {
|
||||||
return queryString.length !== 0 ? `&${queryString}` : '';
|
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) {
|
export function getTaxLineItemQueryString(lineItems, parameterName) {
|
||||||
const queryString = getLineItemsFlattened(lineItems).map((lineItem, index) =>
|
const queryString = getLineItemsFlattened(lineItems).map((lineItem, index) =>
|
||||||
`${parameterName}[${index}].partNumber=${lineItem.partNumber}`
|
`${parameterName}[${index}].partNumber=${lineItem.partNumber}`
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,6 @@ export default {
|
||||||
|
|
||||||
// Call APIs
|
// Call APIs
|
||||||
const cmsContentPromise = fetchCmsContentForPage(to?.query?.issPage);
|
const cmsContentPromise = fetchCmsContentForPage(to?.query?.issPage);
|
||||||
const supportingItemsPromise = store.getSupportingItems();
|
|
||||||
const getRecalPartsPromise = store.getRecalParts();
|
const getRecalPartsPromise = store.getRecalParts();
|
||||||
|
|
||||||
// Settle promises and get results
|
// Settle promises and get results
|
||||||
|
|
@ -167,10 +166,6 @@ export default {
|
||||||
resultKey: 'cmsContent',
|
resultKey: 'cmsContent',
|
||||||
promise: cmsContentPromise
|
promise: cmsContentPromise
|
||||||
},
|
},
|
||||||
{
|
|
||||||
resultKey: 'supportingItems',
|
|
||||||
promise: supportingItemsPromise
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
resultKey: 'recalParts',
|
resultKey: 'recalParts',
|
||||||
promise: getRecalPartsPromise
|
promise: getRecalPartsPromise
|
||||||
|
|
@ -197,7 +192,6 @@ export default {
|
||||||
next(async (vm) => {
|
next(async (vm) => {
|
||||||
showIssLoadingModal(true);
|
showIssLoadingModal(true);
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
vm.setSupportingItems(resultMap.supportingItems);
|
|
||||||
await vm.initializeComponent();
|
await vm.initializeComponent();
|
||||||
if (!vm.unverified) {
|
if (!vm.unverified) {
|
||||||
useMainStore().disableKeyFields();
|
useMainStore().disableKeyFields();
|
||||||
|
|
@ -401,10 +395,9 @@ export default {
|
||||||
showIssLoadingModal(false);
|
showIssLoadingModal(false);
|
||||||
},
|
},
|
||||||
async getPricedParts() {
|
async getPricedParts() {
|
||||||
const { glassParts, supportingItems } = this.mainStore.order.lineItems;
|
const { glassParts } = this.mainStore.order.lineItems;
|
||||||
const availableLineItems = [
|
const availableLineItems = [
|
||||||
...(glassParts ?? []),
|
...(glassParts ?? [])
|
||||||
...(supportingItems ?? [])
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// We only call the ITAC pricing endpoint if we are not repair or we are NoComp
|
// We only call the ITAC pricing endpoint if we are not repair or we are NoComp
|
||||||
|
|
@ -480,9 +473,6 @@ export default {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setSupportingItems(newSupportingItems) {
|
|
||||||
this.mainStore.updateSupportingItems(newSupportingItems);
|
|
||||||
},
|
|
||||||
setBaseServiceLineItems(lineItems) {
|
setBaseServiceLineItems(lineItems) {
|
||||||
this.baseServiceLineItems = lineItems;
|
this.baseServiceLineItems = lineItems;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,9 @@
|
||||||
<script>
|
<script>
|
||||||
// Import Supporting Files
|
// Import Supporting Files
|
||||||
import { AppointmentTypeStrings } from '@/constants/schedule-constants.js';
|
import { AppointmentTypeStrings } from '@/constants/schedule-constants.js';
|
||||||
|
import bailoutMessage from '@/constants/bailoutMessage';
|
||||||
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||||
|
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
||||||
import settleAllPromises from '@/helpers/layout-helper';
|
import settleAllPromises from '@/helpers/layout-helper';
|
||||||
import { required } from '@/helpers/validation-rules';
|
import { required } from '@/helpers/validation-rules';
|
||||||
import errorMessages from '@/constants/error-messages';
|
import errorMessages from '@/constants/error-messages';
|
||||||
|
|
@ -177,17 +179,12 @@ export default {
|
||||||
async beforeRouteEnter(to, from, next) {
|
async beforeRouteEnter(to, from, next) {
|
||||||
// Call APIs
|
// Call APIs
|
||||||
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
|
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 zipCodeData = getZipCodeData(serviceZipCode);
|
||||||
|
|
||||||
const mobileFeePartPromise = getPricedMobileFeePart(serviceZipCode);
|
const mobileFeePartPromise = getPricedMobileFeePart(serviceZipCode);
|
||||||
const serviceabilityDetailsPromise =
|
const serviceabilityDetailsPromise = getServiceabilityDetails(serviceZipCode);
|
||||||
getServiceabilityDetails(serviceZipCode);
|
const shopQuestionInitialDataPromise = shopQuestion.methods.loadInitialData(serviceZipCode);
|
||||||
const shopQuestionInitialDataPromise =
|
const getGlassFeesPromise = useMainStore().getGlassFees();
|
||||||
shopQuestion.methods.loadInitialData(serviceZipCode);
|
|
||||||
|
|
||||||
// Settle promises and get results
|
// Settle promises and get results
|
||||||
const promiseResultMap = [
|
const promiseResultMap = [
|
||||||
|
|
@ -199,6 +196,10 @@ export default {
|
||||||
resultKey: 'mobileFeePart',
|
resultKey: 'mobileFeePart',
|
||||||
promise: mobileFeePartPromise
|
promise: mobileFeePartPromise
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
resultKey: 'glassFees',
|
||||||
|
promise: getGlassFeesPromise
|
||||||
|
},
|
||||||
{
|
{
|
||||||
resultKey: 'serviceabilityDetails',
|
resultKey: 'serviceabilityDetails',
|
||||||
promise: serviceabilityDetailsPromise
|
promise: serviceabilityDetailsPromise
|
||||||
|
|
@ -215,13 +216,14 @@ export default {
|
||||||
|
|
||||||
const resultMap = await settleAllPromises(promiseResultMap);
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
useMainStore().updateIsSafeliteProvider(true);
|
useMainStore().updateIsSafeliteProvider(true);
|
||||||
next((vm) => {
|
next(async (vm) => {
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
vm.setData(
|
await vm.setData(
|
||||||
resultMap.zipCodeData,
|
resultMap.zipCodeData,
|
||||||
resultMap.serviceabilityDetails,
|
resultMap.serviceabilityDetails,
|
||||||
resultMap.mobileFeePart,
|
resultMap.mobileFeePart,
|
||||||
resultMap.shopQuestionInitialData?.mobileProviderNumber
|
resultMap.shopQuestionInitialData?.mobileProviderNumber,
|
||||||
|
resultMap.glassFees
|
||||||
);
|
);
|
||||||
vm.$refs[SHOP_QUESTION_REF_NAME].initializeComponent(resultMap.shopQuestionInitialData);
|
vm.$refs[SHOP_QUESTION_REF_NAME].initializeComponent(resultMap.shopQuestionInitialData);
|
||||||
});
|
});
|
||||||
|
|
@ -308,10 +310,8 @@ export default {
|
||||||
if (newValue.zipCode !== this.zipCode) {
|
if (newValue.zipCode !== this.zipCode) {
|
||||||
if (
|
if (
|
||||||
!(
|
!(
|
||||||
this.selectedAppointmentType
|
this.selectedAppointmentType === AppointmentTypeStrings.MOBILE
|
||||||
=== AppointmentTypeStrings.MOBILE
|
|| this.selectedAppointmentType === AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP
|
||||||
|| this.selectedAppointmentType
|
|
||||||
=== AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP
|
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
this.selectedAppointmentType = null;
|
this.selectedAppointmentType = null;
|
||||||
|
|
@ -393,8 +393,7 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
arePagePrerequisitesValid() {
|
arePagePrerequisitesValid() {
|
||||||
return (
|
return (
|
||||||
useMainStore().lineItems.supportingItems !== null
|
useMainStore().order.serviceLocation.zipCode !== null
|
||||||
&& useMainStore().order.serviceLocation.zipCode !== null
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
async reloadShopData(zipCode) {
|
async reloadShopData(zipCode) {
|
||||||
|
|
@ -471,11 +470,12 @@ export default {
|
||||||
getSelectedProvider() {
|
getSelectedProvider() {
|
||||||
return useMainStore().order.serviceLocation.provider;
|
return useMainStore().order.serviceLocation.provider;
|
||||||
},
|
},
|
||||||
setData(
|
async setData(
|
||||||
zipCodeData,
|
zipCodeData,
|
||||||
serviceabilityDetails,
|
serviceabilityDetails,
|
||||||
mobileFeePart,
|
mobileFeePart,
|
||||||
mobileProviderNumber
|
mobileProviderNumber,
|
||||||
|
glassFees
|
||||||
) {
|
) {
|
||||||
if (zipCodeData) {
|
if (zipCodeData) {
|
||||||
this.zipContainsMilitaryBase = zipCodeData.containsMilitaryBase;
|
this.zipContainsMilitaryBase = zipCodeData.containsMilitaryBase;
|
||||||
|
|
@ -493,12 +493,40 @@ export default {
|
||||||
if (mobileProviderNumber) {
|
if (mobileProviderNumber) {
|
||||||
this.setMobileProviderNumber(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) {
|
setContainsMilitaryBase(val) {
|
||||||
if (this.zipContainsMilitaryBase !== val) {
|
if (this.zipContainsMilitaryBase !== val) {
|
||||||
this.zipContainsMilitaryBase = val;
|
this.zipContainsMilitaryBase = val;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
setGlassFeeItems(newGlassFeeItems) {
|
||||||
|
this.mainStore.updateGlassFees(newGlassFeeItems);
|
||||||
|
},
|
||||||
setMobileFeePart(mobileFeePart) {
|
setMobileFeePart(mobileFeePart) {
|
||||||
this.mobileFeePart = mobileFeePart;
|
this.mobileFeePart = mobileFeePart;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,12 @@ import bailoutMessage from '@/constants/bailoutMessage';
|
||||||
import bailoutCode from '@/constants/bailoutCode';
|
import bailoutCode from '@/constants/bailoutCode';
|
||||||
import partNumberStrings from '@/constants/part-number-strings';
|
import partNumberStrings from '@/constants/part-number-strings';
|
||||||
import { findLineItemIndex, getLineItemsFlattened } from '@/helpers/line-items-helper';
|
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 coverageType from '@/constants/coverage-type';
|
||||||
import { getExperimentSettingValue, getFeatureTogglesQueryString } from '@/helpers/experiment-helper';
|
import { getExperimentSettingValue, getFeatureTogglesQueryString } from '@/helpers/experiment-helper';
|
||||||
import { getSessionKeyValue, getUserIdValue, deleteISSCookie } from '@/helpers/cookie-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() {
|
async getSupportingItems() {
|
||||||
const { glassParts } = this.lineItems;
|
const { glassParts } = this.lineItems;
|
||||||
const { carId } = this.vehicle;
|
const { carId } = this.vehicle;
|
||||||
const { isRepair, numberOfChips } = this.damage;
|
const { isRepair, numberOfChips } = this.damage;
|
||||||
|
|
||||||
console.log('supporting http response..');
|
|
||||||
|
|
||||||
return globalMethods
|
return globalMethods
|
||||||
.callHttpClient({
|
.callHttpClient({
|
||||||
method: endpoints.GetSupportingItems.method,
|
method: endpoints.GetSupportingItems.method,
|
||||||
|
|
@ -1831,7 +1865,15 @@ export const useMainStore = defineStore({
|
||||||
this.order.insuranceCoverage.isItacOptimized = false;
|
this.order.insuranceCoverage.isItacOptimized = false;
|
||||||
this.order.insuranceCoverage.claimNumber = null;
|
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) {
|
updateSupportingItems(partsData) {
|
||||||
if (partsData == null) {
|
if (partsData == null) {
|
||||||
this.order.lineItems.supportingItems = null;
|
this.order.lineItems.supportingItems = null;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue