diff --git a/src/global-methods.js b/src/global-methods.js index 2717cbda9..ffda1e77f 100644 --- a/src/global-methods.js +++ b/src/global-methods.js @@ -9,18 +9,12 @@ import { headerKeys } from "@/constants/header-keys"; export default { callHttpClient({ method, endpoint, payload, logApiCall = true }) { return new Promise((resolve, reject) => { - let cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO; + const cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO; const payloadAndAnalyticsData = Object.assign({}, payload, { AppName: "FixMyGlass" }); const headers = { [headerKeys.EXPERIMENT]: JSON.stringify(store.getters.experimentSettings) } - 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..2869c3358 100644 --- a/src/helpers/heritage-integration/order-helper.js +++ b/src/helpers/heritage-integration/order-helper.js @@ -36,6 +36,11 @@ export async function loadOrderIfPresent() { update the cookie. */ export async function saveOrder() { + store.dispatch(storeActions.RUN_EXPERIMENTS_FOR_TRIGGER, { + userId: "test", + triggerEvent: "test", + triggerValue: "test" + }) 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 707fc61c1..64d451f63 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -377,20 +377,20 @@ export const getters = { serviceZipCode: state.order.serviceLocation.zipCode, parentAccountNumber: state.order.accountNumber, isCoverageVerified: state.order.payment.insuranceCoverage.isVerified, - 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")], + orderPartNumbers: [...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts, "partNumber"), ...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.otherParts, "partNumber")], + orderPartTypes: [...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts, "recalibrationType"), ...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.otherParts, "recalibrationType")], hasRecalibrationPart: (state.order.lineItems.glassParts ?? []).filter(x => x.requiresRecalibration)?.length > 0, selectedMultiGlass: state.order.damage.glassToReplace?.length > 1, - 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) + selectedWindshieldGlass: getAllValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.WINDSHIELD), + selectedBackGlass: getAllValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.REAR), + selectedDriverSideGlass: getAllValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.DRIVER), + selectedPassengerSideGlass: getAllValuesOfPropertyInArrayOfObjects(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) { +function getAllValuesOfPropertyInArrayOfObjects(array, propertyName) { return (array ?? []).map(x => x[propertyName]).filter(x => x); }