diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index c1771b3f5..4471b1011 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -216,6 +216,10 @@ const endpoints = { url: "/order/api/v1/order/add-donation-part", method: "POST", }, + GetOemAfterMarketParts: { + url: "/parts/api/v1/parts/oem-after-market-parts", + method: "POST", + }, }; export { endpoints }; diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index 513891ea1..2bbfc87fa 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -23,6 +23,7 @@ const storeActions = { GET_ALERT_REASONS_BY_CTU: "getAlertReasonsByCtu", GET_PARTS_OR_QUESTIONS: "getPartsOrQuestions", GET_PARTS: "getParts", + GET_OEM_AFTERMARKET_PARTS: "getOemAfterMarketParts", GET_WIPERS: "getWipers", GET_RAIN_REPEL: "getRainRepel", GET_SUPPORTING_ITEMS: "getSupportingItems", diff --git a/src/layouts/quote/quote.vue b/src/layouts/quote/quote.vue index dabc39fd7..5b874ad0c 100644 --- a/src/layouts/quote/quote.vue +++ b/src/layouts/quote/quote.vue @@ -219,6 +219,13 @@ export default { "quote" ); + // call API oem-after-market-parts method + const oemAfterMarketParts = baseMixin.methods.dispatchStoreActionWithLogging( + storeActions.GET_OEM_AFTERMARKET_PARTS, + null, + "quote" + ); + const shouldExposeSkipQuote = store.getters.isRecalibrationOnOrder; const skipQuoteExperiment = store.getters.applicationUser.experiments.find( (e) => e.universeName === experimentUniverses.IGQ_SkipQuote diff --git a/src/store/index.js b/src/store/index.js index ca1d76f6f..b94fe17a8 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1836,6 +1836,54 @@ export const actions = { return response; }, + // Parts API Actions + async getOemAfterMarketParts(context, { pageNameToLog }) { + const vehicle = context.getters.vehicle; + const damage = context.getters.damage; + const order = context.state.order; + + const carId = vehicle.carId; + const glassArray = damage.glassToReplace; + const resultsArray = damage.partQuestionAnswers; + const zipCode = order.serviceLocation.zipCode; + const vin = vehicle.vin; + const make = vehicle.make; + const serviceType = order.serviceLocation?.appointmentType; + const referralSeqNumber = order.referralSequenceNumber; + const parentAccountNumber = applicationConfig.CASH_PARENT_ACCOUNT_NUMBER; + const oemEndorsementFlag = false; // Need to update from the store when available + + // create a new array to avoid mutating state + const glassArrayForPayload = convertGlassPieceNamingForApi(glassArray); + const resultsArrayForPayload = convertResultsForApi(resultsArray); + + const response = await globalMethods.callHttpClient({ + method: endpoints.GetOemAfterMarketParts.method, + endpoint: endpoints.GetOemAfterMarketParts.url, + payload: { + carId: carId, + glassPieces: glassArrayForPayload, + answerResults: resultsArrayForPayload, + zip: zipCode, + vin: vin, + serviceType: serviceType, + referralSeqNumber: referralSeqNumber, + make: make, + parentAccountNumber: parentAccountNumber.toString(), + oemEndorsementFlag: oemEndorsementFlag, + }, + logApiCall: true, + pageNameToLog: pageNameToLog, + }); + + // Flatten location and name properties + response.data.glassPieceParts = convertGlassPieceNamingFromApi( + response.data.glassPieceParts + ); + + return response; + }, + async getWipers(context, { payload, pageNameToLog }) { const carId = payload.carId; const serviceZipCode = payload.serviceZipCode;