From 2167c240bbba9bebd38a99c7e92063bfe65f57be Mon Sep 17 00:00:00 2001 From: Katie Date: Tue, 9 Aug 2022 13:22:23 -0400 Subject: [PATCH] CSR-514 Fix experimentOrder --- src/global-methods.js | 4 +++- .../heritage-integration/order-helper.js | 8 ++++++++ src/store/index.js | 18 +++++++++++------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/global-methods.js b/src/global-methods.js index 0da6824ef..2717cbda9 100644 --- a/src/global-methods.js +++ b/src/global-methods.js @@ -18,7 +18,9 @@ export default { if (endpoint.includes("/experiments/")) { cfDistroUrl = "https://localhost:44372"; } - + else if (endpoint.includes("/order/")) + cfDistroUrl = "https://localhost:44346" + axios({ method: method, url: cfDistroUrl + endpoint, data: payloadAndAnalyticsData, crossDomain: true, responseType: {}, headers: headers }) .then((response) => { diff --git a/src/helpers/heritage-integration/order-helper.js b/src/helpers/heritage-integration/order-helper.js index 870ee190b..4c18b660f 100644 --- a/src/helpers/heritage-integration/order-helper.js +++ b/src/helpers/heritage-integration/order-helper.js @@ -36,6 +36,14 @@ export async function loadOrderIfPresent() { update the cookie. */ export async function saveOrder() { + // TODO DELETE THIS, TEMP FOR TESTING + baseMixin.methods.dispatchStoreAction(storeActions.RUN_EXPERIMENTS_FOR_TRIGGER, { + userId: "test", + triggerEvent: "test", + triggerValue: "test" + }) + // END DELETE + var saveOrderPromise; if (store.getters.applicationUser.saveOrderPromise) { // queue newest request after current saveOrderPromise resolves diff --git a/src/store/index.js b/src/store/index.js index dbe18ef04..0ae01ad66 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -362,19 +362,23 @@ export const getters = { serviceZipCode: state.order.serviceLocation.zipCode, parentAccountNumber: state.order.accountNumber, isCoverageVerified: state.order.payment.insuranceCoverage.isVerified, - orderPartNumbers: [...Object.values(state.order.lineItems.glassParts ?? []), ...Object.values(state.order.lineItems.otherParts ?? [])], - orderPartTypes: [...Object.keys(state.order.lineItems.glassParts ?? []), ...Object.keys(state.order.lineItems.otherParts ?? [])], - hasRecalibrationPart: Object.values(state.order.lineItems.glassParts ?? []).filter(x => x.requiresRecalibration)?.length > 0, + orderPartNumbers: [...testHelper(state.order.lineItems.glassParts, "partNumber"), ...testHelper(state.order.lineItems.otherParts, "partNumber")], + orderPartTypes: [...testHelper(state.order.lineItems.glassParts, "recalibrationType"), ...testHelper(state.order.lineItems.otherParts, "recalibrationType")], + hasRecalibrationPart: (state.order.lineItems.glassParts ?? []).filter(x => x.requiresRecalibration)?.length > 0, selectedMultiGlass: state.order.damage.glassToReplace?.length > 1, - selectedWindshieldGlass: (state.order.damage.glassToReplace ?? []).map(x => x.glassLocation).includes(damageLocationsSelected.WINDSHIELD), - selectedBackGlass: (state.order.damage.glassToReplace ?? []).map(x => x.glassLocation).includes(damageLocationsSelected.REAR), - selectedDriverSideGlass: (state.order.damage.glassToReplace ?? []).map(x => x.glassLocation).includes(damageLocationsSelected.DRIVER), - selectedPassengerSideGlass: (state.order.damage.glassToReplace ?? []).map(x => x.glassLocation).includes(damageLocationsSelected.PASSENGER) + selectedWindshieldGlass: testHelper(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.WINDSHIELD), + selectedBackGlass: testHelper(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.REAR), + selectedDriverSideGlass: testHelper(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.DRIVER), + selectedPassengerSideGlass: testHelper(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.PASSENGER) } }, experimentSettings: (state) => state.applicationUser.experiments.map(x => x.settings).reduce((r, c) => Object.assign(r, c), {}) } +function testHelper(array, propertyName) { + return (array ?? []).map(x => x[propertyName]).filter(x => x); +} + // Export Actions export const actions = {