CSR-514 Cleanup
This commit is contained in:
parent
c55d068edd
commit
2a28fea2dd
3 changed files with 13 additions and 14 deletions
|
|
@ -9,18 +9,12 @@ import { headerKeys } from "@/constants/header-keys";
|
||||||
export default {
|
export default {
|
||||||
callHttpClient({ method, endpoint, payload, logApiCall = true }) {
|
callHttpClient({ method, endpoint, payload, logApiCall = true }) {
|
||||||
return new Promise((resolve, reject) => {
|
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 payloadAndAnalyticsData = Object.assign({}, payload, { AppName: "FixMyGlass" });
|
||||||
const headers = {
|
const headers = {
|
||||||
[headerKeys.EXPERIMENT]: JSON.stringify(store.getters.experimentSettings)
|
[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 })
|
axios({ method: method, url: cfDistroUrl + endpoint, data: payloadAndAnalyticsData, crossDomain: true, responseType: {}, headers: headers })
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,11 @@ export async function loadOrderIfPresent() {
|
||||||
update the cookie.
|
update the cookie.
|
||||||
*/
|
*/
|
||||||
export async function saveOrder() {
|
export async function saveOrder() {
|
||||||
|
store.dispatch(storeActions.RUN_EXPERIMENTS_FOR_TRIGGER, {
|
||||||
|
userId: "test",
|
||||||
|
triggerEvent: "test",
|
||||||
|
triggerValue: "test"
|
||||||
|
})
|
||||||
var saveOrderPromise;
|
var saveOrderPromise;
|
||||||
if (store.getters.applicationUser.saveOrderPromise) {
|
if (store.getters.applicationUser.saveOrderPromise) {
|
||||||
// queue newest request after current saveOrderPromise resolves
|
// queue newest request after current saveOrderPromise resolves
|
||||||
|
|
|
||||||
|
|
@ -377,20 +377,20 @@ export const getters = {
|
||||||
serviceZipCode: state.order.serviceLocation.zipCode,
|
serviceZipCode: state.order.serviceLocation.zipCode,
|
||||||
parentAccountNumber: state.order.accountNumber,
|
parentAccountNumber: state.order.accountNumber,
|
||||||
isCoverageVerified: state.order.payment.insuranceCoverage.isVerified,
|
isCoverageVerified: state.order.payment.insuranceCoverage.isVerified,
|
||||||
orderPartNumbers: [...testHelper(state.order.lineItems.glassParts, "partNumber"), ...testHelper(state.order.lineItems.otherParts, "partNumber")],
|
orderPartNumbers: [...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts, "partNumber"), ...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.otherParts, "partNumber")],
|
||||||
orderPartTypes: [...testHelper(state.order.lineItems.glassParts, "recalibrationType"), ...testHelper(state.order.lineItems.otherParts, "recalibrationType")],
|
orderPartTypes: [...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.glassParts, "recalibrationType"), ...getAllValuesOfPropertyInArrayOfObjects(state.order.lineItems.otherParts, "recalibrationType")],
|
||||||
hasRecalibrationPart: (state.order.lineItems.glassParts ?? []).filter(x => x.requiresRecalibration)?.length > 0,
|
hasRecalibrationPart: (state.order.lineItems.glassParts ?? []).filter(x => x.requiresRecalibration)?.length > 0,
|
||||||
selectedMultiGlass: state.order.damage.glassToReplace?.length > 1,
|
selectedMultiGlass: state.order.damage.glassToReplace?.length > 1,
|
||||||
selectedWindshieldGlass: testHelper(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.WINDSHIELD),
|
selectedWindshieldGlass: getAllValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.WINDSHIELD),
|
||||||
selectedBackGlass: testHelper(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.REAR),
|
selectedBackGlass: getAllValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.REAR),
|
||||||
selectedDriverSideGlass: testHelper(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.DRIVER),
|
selectedDriverSideGlass: getAllValuesOfPropertyInArrayOfObjects(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.DRIVER),
|
||||||
selectedPassengerSideGlass: testHelper(state.order.damage.glassToReplace, "glassLocation").includes(damageLocationsSelected.PASSENGER)
|
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), {})
|
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);
|
return (array ?? []).map(x => x[propertyName]).filter(x => x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue