From a299e558c11fee9653ab3ae3df8bf84b2cdd4056 Mon Sep 17 00:00:00 2001 From: Katie Date: Mon, 5 Dec 2022 08:52:15 -0500 Subject: [PATCH] CSR-747 WIP --- src/constants/endpoints.js | 4 ++ src/constants/store-actions.js | 1 + src/global-methods.js | 4 ++ src/layouts/quote/quote.vue | 5 ++ src/store/index.js | 117 ++++++++++++++++++++++++++++++--- 5 files changed, 122 insertions(+), 9 deletions(-) diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index 3024a67d9..f1eaa65b2 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -122,6 +122,10 @@ const endpoints = { url: "/experiments/api/v1/experiments/run", method: "POST", }, + GetPriceForLineItems: { + url: "/price/api/v1/price/order-items", + method: "GET" + } }; export { endpoints }; diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index 1ac58935c..8c94ef63c 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -40,6 +40,7 @@ const storeActions = { RUN_EXPERIMENTS_FOR_TRIGGER: "runExperimentsForTrigger", CLEAR_VIN: "clearVin", RESET_SAVE_SESSION_PROMISE: "resetSaveSessionPromise", + GET_PRICES_FOR_LINE_ITEMS: "getPricesForLineItems", // DEPENDENCY MUTATIONS RESET_DAMAGE_STATE_AND_DEPENDENCIES: "resetDamageAndDependencies", diff --git a/src/global-methods.js b/src/global-methods.js index 1472e0f92..d93232af9 100644 --- a/src/global-methods.js +++ b/src/global-methods.js @@ -10,9 +10,13 @@ export default { callHttpClient({ method, endpoint, payload, logApiCall = true }) { return new Promise((resolve, reject) => { let cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO; + if (endpoint.includes("/order/")) { cfDistroUrl = "https://localhost:44346"; } + else if (endpoint.includes("/price/")) { + cfDistroUrl = "https://localhost:44372"; + } const payloadAndAnalyticsData = Object.assign({}, payload, { AppName: "FixMyGlass" }); const headers = { diff --git a/src/layouts/quote/quote.vue b/src/layouts/quote/quote.vue index 15b8609c1..72cfb628c 100644 --- a/src/layouts/quote/quote.vue +++ b/src/layouts/quote/quote.vue @@ -8,6 +8,7 @@ :displayGenericVehicleImage="false" />
+ 0); diff --git a/src/store/index.js b/src/store/index.js index de5fa33df..39f1b247c 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -9,7 +9,7 @@ import { applicationConfig } from "@/constants/application-config"; import { experimentTriggers } from "@/constants/experiments"; import { damageLocationsSelected } from "@/constants/damage-locations-selected"; import { fmgPageValues } from "@/router/router-constants/fmgPage-values"; -import router from "@/router" +import router from "@/router"; // Export State const getDefaultState = () => { @@ -63,7 +63,7 @@ const getDefaultState = () => { isInsurance: null, insuranceCoverage: { isVerified: null, - coverageStatus: null + coverageStatus: null, }, }, referralNumber: null, @@ -83,12 +83,6 @@ const getDefaultState = () => { experiments: [], triggeredSiteEntry: false, }, - // gaClickInformation: { - // currentlySelectedValues: {}, - // firedGaClickEventValues: {}, - // lastFocusedInputGroup: "", - // wasLastFocusedInputMultiselect: undefined, - // }, }; }; @@ -920,7 +914,7 @@ export const actions = { const carId = context.getters.vehicle.carId; const isRepair = context.getters.damage.isRepair; const numberOfChips = context.getters.damage.numberOfChips; - const parentAccountNumber = context.getters.order.accountNumber.toString(); + const parentAccountNumber = "167132"//context.getters.order.accountNumber.toString(); return globalMethods.callHttpClient({ method: endpoints.GetSupportingItems.method, endpoint: endpoints.GetSupportingItems.url, @@ -1067,6 +1061,111 @@ export const actions = { }); }, + // START Pricing service call actions + getPricesForLineItems(context) { + const vehicle = context.getters.vehicle; + const lineItems = { + glassParts: [ + { + partNumber: "FW04186GTYN", + description: "solar, soundproofing, lane keep assist", + color: "Green Tint", + requiresRecalibration: true, + requiresCapabilityQuestions: false, + recalibrationType: "DUAL", + childParts: [ + { + partNumber: "GGG 3563 KIT", + }, + ], + }, + { + partNumber: "FD25457GTYN", + description: "solar, driver side, rear", + color: "Green Tint", + requiresRecalibration: false, + requiresCapabilityQuestions: false, + recalibrationType: "", + childParts: null, + }, + { + partNumber: "FD27090GTYN", + description: "solar, driver side, front", + color: "Green Tint", + requiresRecalibration: false, + requiresCapabilityQuestions: false, + recalibrationType: "", + childParts: null, + }, + { + partNumber: "FB25460GTYN", + description: "heated glass, solar", + color: "Green Tint", + requiresRecalibration: false, + requiresCapabilityQuestions: false, + recalibrationType: "", + childParts: null, + }, + ], + supportingItems: [ + { + partNumber: "PART1", + description: "solar, soundproofing, lane keep assist", + color: "Green Tint", + requiresRecalibration: true, + requiresCapabilityQuestions: false, + recalibrationType: "DUAL", + childParts: [ + { + partNumber: "GGG 3563 KIT", + }, + ], + }, + { + partNumber: "PART2", + description: "solar, driver side, rear", + color: "Green Tint", + requiresRecalibration: false, + requiresCapabilityQuestions: false, + recalibrationType: "", + childParts: null, + }, + ], + }; + + const commaSeparatedPartNumbers = Object.values(context.getters.order.lineItems) + .map((lineItemGroup) => lineItemGroup.map((lineItem) => lineItem.partNumber)) + .flat() + .join(","); + + console.log({ + lineItems: Object.values(lineItems) + .map((lineItemGroup) => lineItemGroup.map((lineItem) => lineItem.partNumber)) + .flat() + .join(","), + commaSeparatedPartNumbers, + }); + + // context.getters.order.lineItems.map(lineItemGroup => ) + + return globalMethods + .callHttpClient({ + method: endpoints.GetPriceForLineItems.method, + endpoint: `${endpoints.GetPriceForLineItems.url}?CTU=01833&carId=${vehicle.carId}&make=${vehicle.make}&model=${vehicle.model}&year=${vehicle.year}&EON=S169140586&zipCode=34785&lineItems=${commaSeparatedPartNumbers}&parentAccountNumber=167132`, + }) + .then((response) => { + // Flatten location and name properties + + // clear the state if the existing EON does not equal what is returned from loadSession + // if (context.state.order.eon && context.state.order.eon != response.data.eon) { + // context.commit(storeMutations.RESET_STATE); + // } + // context.commit(storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION, response.data); + return response; + }); + }, + // END Pricing service call actions + // Business domain actions // Vehicle