IO-1702 OEC Price.
This commit is contained in:
@@ -30,6 +30,8 @@ import AlertComponent from "../alert/alert.component";
|
|||||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||||
import PartsOrderModalComponent from "./parts-order-modal.component";
|
import PartsOrderModalComponent from "./parts-order-modal.component";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { useTreatments } from "@splitsoftware/splitio-react";
|
||||||
|
import _ from "lodash";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
currentUser: selectCurrentUser,
|
currentUser: selectCurrentUser,
|
||||||
@@ -57,6 +59,11 @@ export function PartsOrderModalContainer({
|
|||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const client = useApolloClient();
|
const client = useApolloClient();
|
||||||
|
const { OEConnection_PriceChange } = useTreatments(
|
||||||
|
["OEConnection_PriceChange"],
|
||||||
|
{},
|
||||||
|
bodyshop.imexshopid
|
||||||
|
);
|
||||||
const { visible, context, actions } = partsOrderModal;
|
const { visible, context, actions } = partsOrderModal;
|
||||||
const {
|
const {
|
||||||
jobId,
|
jobId,
|
||||||
@@ -230,11 +237,22 @@ export function PartsOrderModalContainer({
|
|||||||
id: insertResult.data.insert_parts_orders.returning[0].id,
|
id: insertResult.data.insert_parts_orders.returning[0].id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
let po;
|
||||||
|
//Massage the data based on the split. Should they be able to overwrite OEC pricing?
|
||||||
|
if (OEConnection_PriceChange.treatment === "on") {
|
||||||
|
//Set the flag to include the override.
|
||||||
|
po = _.cloneDeep(partsOrder.data.parts_orders_by_pk);
|
||||||
|
po.parts_order_lines.forEach((pol) => {
|
||||||
|
pol.priceChange = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(partsOrder.data.parts_orders_by_pk);
|
||||||
|
|
||||||
const oecResponse = await axios.post(
|
const oecResponse = await axios.post(
|
||||||
"http://localhost:1337/oec/",
|
"http://localhost:1337/oec/",
|
||||||
|
|
||||||
partsOrder.data.parts_orders_by_pk,
|
po || partsOrder.data.parts_orders_by_pk,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${await auth.currentUser.getIdToken()}`,
|
Authorization: `Bearer ${await auth.currentUser.getIdToken()}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user