Merge pull request #854 from Safelite/feature/richardson/SSR-1477
Updates for getting recal parts as child parts
This commit is contained in:
commit
07e6e01b77
4 changed files with 70 additions and 3 deletions
|
|
@ -104,6 +104,19 @@ const endpoints = Object.freeze({
|
|||
url: `${PARTS_BASE_URL}/rain-defense`,
|
||||
method: 'GET'
|
||||
},
|
||||
GetRecalParts: {
|
||||
url: (
|
||||
carId,
|
||||
partNumber,
|
||||
recalibrationType,
|
||||
parentAccountNumber,
|
||||
zipCode,
|
||||
applicationName,
|
||||
referralSequenceNumber
|
||||
// eslint-disable-next-line max-len
|
||||
) => `${PARTS_BASE_URL}/recal-parts/${carId}/${partNumber}/${recalibrationType}/${parentAccountNumber}/${zipCode}/${applicationName}/${referralSequenceNumber}`,
|
||||
method: 'GET'
|
||||
},
|
||||
GetSupportingItems: {
|
||||
url: `${PARTS_BASE_URL}/supporting-items`,
|
||||
method: 'POST'
|
||||
|
|
|
|||
|
|
@ -159,6 +159,7 @@ export default {
|
|||
// Call APIs
|
||||
const cmsContentPromise = fetchCmsContentForPage(to?.query?.issPage);
|
||||
const supportingItemsPromise = store.getSupportingItems();
|
||||
const getRecalPartsPromise = store.getRecalParts();
|
||||
|
||||
// Settle promises and get results
|
||||
const promiseResultMap = [
|
||||
|
|
@ -169,6 +170,10 @@ export default {
|
|||
{
|
||||
resultKey: 'supportingItems',
|
||||
promise: supportingItemsPromise
|
||||
},
|
||||
{
|
||||
resultKey: 'recalParts',
|
||||
promise: getRecalPartsPromise
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -414,8 +414,8 @@ export default {
|
|||
);
|
||||
|
||||
if (this.isWindshieldRepair) {
|
||||
const supportingItems =
|
||||
await useMainStore().getSupportingItems();
|
||||
const results = await Promise.allSettled([useMainStore().getSupportingItems(), useMainStore().getRecalParts()]);
|
||||
const supportingItems = results[0];
|
||||
useMainStore().updateSupportingItems(supportingItems.data);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1020,11 +1020,60 @@ export const useMainStore = defineStore({
|
|||
}).catch((error) => reject(error));
|
||||
});
|
||||
},
|
||||
async getRecalParts() {
|
||||
const { glassParts } = this.lineItems;
|
||||
const { carId } = this.vehicle;
|
||||
const { parentAccountNumber, referralSequenceNumber } = this.order;
|
||||
const { zipCode } = this.order.serviceLocation;
|
||||
|
||||
if (glassParts && glassParts.length > 0) {
|
||||
const recalPromises = [];
|
||||
glassParts.forEach((glassPart) => {
|
||||
if (glassPart.requiresRecalibration) {
|
||||
const partNumberChecked = glassPart.partNumber;
|
||||
recalPromises.push(globalMethods
|
||||
.callHttpClient({
|
||||
method: endpoints.GetRecalParts.method,
|
||||
endpoint: endpoints.GetRecalParts.url(
|
||||
carId,
|
||||
partNumberChecked,
|
||||
glassPart.recalibrationType,
|
||||
parentAccountNumber,
|
||||
zipCode,
|
||||
applicationConfig.APPLICATION_NAME,
|
||||
referralSequenceNumber
|
||||
)
|
||||
})
|
||||
.then((response) => {
|
||||
const recalResponse = response.data;
|
||||
if (recalResponse && recalResponse.recalibrationParts && recalResponse.recalibrationParts.length > 0) {
|
||||
this.addGlassPartRecalibrationInfo(partNumberChecked, recalResponse.recalibrationParts[0]);
|
||||
}
|
||||
}));
|
||||
}
|
||||
});
|
||||
await Promise.allSettled(recalPromises);
|
||||
}
|
||||
},
|
||||
addGlassPartRecalibrationInfo(partNumber, recalPartInformation) {
|
||||
const glassPart = this.lineItems.glassParts.find((gp) => gp.partNumber === partNumber);
|
||||
if (glassPart) {
|
||||
const recalChildPart = glassPart.childParts?.find((cp) => cp.partNumber === recalPartInformation.partNumber);
|
||||
if (!recalChildPart) {
|
||||
if (!Array.isArray(glassPart.childParts) || !glassPart.childParts.length) {
|
||||
glassPart.childParts = [];
|
||||
}
|
||||
glassPart.childParts.push(recalPartInformation);
|
||||
}
|
||||
}
|
||||
},
|
||||
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,
|
||||
|
|
@ -1212,7 +1261,7 @@ export const useMainStore = defineStore({
|
|||
facilityType: 'Mobile',
|
||||
parentAccountNumber: this.order.parentAccountNumber,
|
||||
billToAccountNumber: this.billToAccountNumber,
|
||||
isItacOptimized: false, //TODO: Implement with response from getITACPriceOrderItems
|
||||
isItacOptimized: false, // TODO: Implement with response from getITACPriceOrderItems
|
||||
providerNumber: this.providerNumber,
|
||||
carId: vehicle.carId,
|
||||
coverageStatus: coverageStatuses.mapToApi(insuranceCoverage.coverageStatus),
|
||||
|
|
|
|||
Loading…
Reference in a new issue