Updates for getting recal parts as child parts
This commit is contained in:
parent
91e7920192
commit
29c7125783
4 changed files with 65 additions and 2 deletions
|
|
@ -104,6 +104,19 @@ const endpoints = Object.freeze({
|
||||||
url: `${PARTS_BASE_URL}/rain-defense`,
|
url: `${PARTS_BASE_URL}/rain-defense`,
|
||||||
method: 'GET'
|
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: {
|
GetSupportingItems: {
|
||||||
url: `${PARTS_BASE_URL}/supporting-items`,
|
url: `${PARTS_BASE_URL}/supporting-items`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,7 @@ export default {
|
||||||
// Call APIs
|
// Call APIs
|
||||||
const cmsContentPromise = fetchCmsContentForPage(to?.query?.issPage);
|
const cmsContentPromise = fetchCmsContentForPage(to?.query?.issPage);
|
||||||
const supportingItemsPromise = store.getSupportingItems();
|
const supportingItemsPromise = store.getSupportingItems();
|
||||||
|
const getRecalPartsPromise = store.getRecalParts();
|
||||||
|
|
||||||
// Settle promises and get results
|
// Settle promises and get results
|
||||||
const promiseResultMap = [
|
const promiseResultMap = [
|
||||||
|
|
@ -169,6 +170,10 @@ export default {
|
||||||
{
|
{
|
||||||
resultKey: 'supportingItems',
|
resultKey: 'supportingItems',
|
||||||
promise: supportingItemsPromise
|
promise: supportingItemsPromise
|
||||||
|
},
|
||||||
|
{
|
||||||
|
resultKey: 'recalParts',
|
||||||
|
promise: getRecalPartsPromise
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -414,8 +414,8 @@ export default {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.isWindshieldRepair) {
|
if (this.isWindshieldRepair) {
|
||||||
const supportingItems =
|
await useMainStore().getRecalParts();
|
||||||
await useMainStore().getSupportingItems();
|
const supportingItems = await useMainStore().getSupportingItems();
|
||||||
useMainStore().updateSupportingItems(supportingItems.data);
|
useMainStore().updateSupportingItems(supportingItems.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1020,6 +1020,51 @@ export const useMainStore = defineStore({
|
||||||
}).catch((error) => reject(error));
|
}).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) {
|
||||||
|
glassParts.forEach((glassPart) => {
|
||||||
|
if (glassPart.requiresRecalibration) {
|
||||||
|
const partNumberChecked = glassPart.partNumber;
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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() {
|
async getSupportingItems() {
|
||||||
const { glassParts } = this.lineItems;
|
const { glassParts } = this.lineItems;
|
||||||
const { carId } = this.vehicle;
|
const { carId } = this.vehicle;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue