Add call to recal endpoint
This commit is contained in:
parent
fede1fe980
commit
e54ead578e
4 changed files with 56 additions and 1 deletions
|
|
@ -84,6 +84,10 @@ const endpoints = {
|
|||
url: "/parts/api/v1/parts/supporting-items",
|
||||
method: "POST",
|
||||
},
|
||||
GetRecalPart: {
|
||||
url: "/parts/api/v1/parts/recal-parts",
|
||||
method: "GET",
|
||||
},
|
||||
GetAlertReasons: {
|
||||
url: "/location/api/v1/location/alert-reasons",
|
||||
method: "GET",
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ const storeActions = {
|
|||
VALIDATE_ORDER_PROMO_AND_SAVE_SERVER_DATA: "validateOrderPromoAndSaveServerData",
|
||||
REVALIDATE_ORDER_PROMOS_AND_SAVE_SERVER_DATA: "revalidateOrderPromosAndSaveServerData",
|
||||
GET_INSURANCE_COMPANY_LIST: "getInsuranceCompanyList",
|
||||
GET_RECAL_PARTS_AND_SAVE_TO_LINE_ITEMS: "getRecalPartsAndSaveToLineItems",
|
||||
|
||||
// DEPENDENCY MUTATIONS
|
||||
RESET_DAMAGE_STATE_AND_DEPENDENCIES: "resetDamageAndDependencies",
|
||||
|
|
|
|||
|
|
@ -450,7 +450,17 @@ export default {
|
|||
const collectedGlassParts = this.reducedGlassPartsArray(partsOrQuestions);
|
||||
|
||||
// save to store lineItems.glassParts
|
||||
self.dispatchStoreAction(storeActions.SAVE_GLASS_PARTS, collectedGlassParts, false);
|
||||
await self.dispatchStoreAction(
|
||||
storeActions.SAVE_GLASS_PARTS,
|
||||
collectedGlassParts,
|
||||
false
|
||||
);
|
||||
|
||||
await self.dispatchStoreActionWithLogging(
|
||||
storeActions.GET_RECAL_PARTS_AND_SAVE_TO_LINE_ITEMS,
|
||||
null,
|
||||
currentPage
|
||||
);
|
||||
|
||||
const payment = store.getters.payment;
|
||||
|
||||
|
|
|
|||
|
|
@ -2855,6 +2855,46 @@ export const actions = {
|
|||
externalParameterMMS.externalParameterStyle
|
||||
);
|
||||
},
|
||||
|
||||
async getRecalPartsAndSaveToLineItems(context, { pageNameToLog }) {
|
||||
// identify each part that needs recal
|
||||
const glassParts = context.state.order?.lineItems?.glassParts ?? [];
|
||||
|
||||
for (let i = 0; i < glassParts.length; i++) {
|
||||
// does this part need recal?
|
||||
const needsRecal =
|
||||
!!glassParts[i].requiresRecalibration && !!glassParts[i].recalibrationType;
|
||||
|
||||
if (needsRecal) {
|
||||
const recalType = glassParts[i].recalibrationType;
|
||||
const parentAccountNumber =
|
||||
context.state.order.payment.parentAccountNumber ??
|
||||
applicationConfig.CASH_PARENT_ACCOUNT_NUMBER;
|
||||
|
||||
// Get part from API
|
||||
const urlExtension = `${context.state.order.vehicle.carId}/${glassParts[i].partNumber}/${recalType}/${parentAccountNumber}/${context.state.order.serviceLocation.zipCode}/${applicationConfig.ANALYTICS_APPLICATION_NAME}/${context.state.order.referralSequenceNumber}`;
|
||||
|
||||
const recalPartResponse = await globalMethods.callHttpClient({
|
||||
method: endpoints.GetRecalPart.method,
|
||||
endpoint: `${endpoints.GetRecalPart.url}/${urlExtension}`,
|
||||
payload: {},
|
||||
pageNameToLog: pageNameToLog,
|
||||
});
|
||||
|
||||
// If any parts retrieved, add as children to the glass part.
|
||||
if (
|
||||
recalPartResponse.status === 200 &&
|
||||
recalPartResponse.data.recalibrationParts?.length > 0
|
||||
) {
|
||||
if (!glassParts[i].childParts) {
|
||||
glassParts[i].childParts = [];
|
||||
}
|
||||
|
||||
glassParts[i].childParts.push(...recalPartResponse.data.recalibrationParts);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default createStore({
|
||||
|
|
|
|||
Loading…
Reference in a new issue