IO-70 Add OEC Through Partner Call.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { Button } from "antd";
|
||||
import axios from "axios";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import { useTranslation } from "react-i18next";
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
bodyshop: selectBodyshop,
|
||||
@@ -19,7 +19,7 @@ export function DmsCdkMakesRefetch({ bodyshop, form, socket }) {
|
||||
const { t } = useTranslation();
|
||||
const handleRefetch = async () => {
|
||||
setLoading(true);
|
||||
const response = await axios.post("/cdk/getvehicles", {
|
||||
await axios.post("/cdk/getvehicles", {
|
||||
cdk_dealerid: bodyshop.cdk_dealerid,
|
||||
bodyshopid: bodyshop.id,
|
||||
});
|
||||
|
||||
@@ -10,14 +10,11 @@ export default function HelpRescue() {
|
||||
var bodyFormData = new FormData();
|
||||
bodyFormData.append("Code", code);
|
||||
bodyFormData.append("hostederrorhandling", 1);
|
||||
const res1 = await fetch(
|
||||
"https://secure.logmeinrescue.com/Customer/Code.aspx",
|
||||
{
|
||||
mode: "no-cors",
|
||||
method: "POST",
|
||||
body: bodyFormData,
|
||||
}
|
||||
);
|
||||
await fetch("https://secure.logmeinrescue.com/Customer/Code.aspx", {
|
||||
mode: "no-cors",
|
||||
method: "POST",
|
||||
body: bodyFormData,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -164,6 +164,7 @@ export default function PartsOrderModalComponent({
|
||||
<Radio value={"none"}>{t("general.labels.none")}</Radio>
|
||||
<Radio value={"e"}>{t("parts_orders.labels.email")}</Radio>
|
||||
<Radio value={"p"}>{t("parts_orders.labels.print")}</Radio>
|
||||
<Radio value={"oec"}>{t("parts_orders.labels.oec")}</Radio>
|
||||
</Radio.Group>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import { useMutation, useQuery } from "@apollo/client";
|
||||
import { useMutation, useQuery, useApolloClient } from "@apollo/client";
|
||||
import { Form, Modal, notification } from "antd";
|
||||
import moment from "moment";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import { logImEXEvent, auth } from "../../firebase/firebase.utils";
|
||||
import { UPDATE_JOB_LINE_STATUS } from "../../graphql/jobs-lines.queries";
|
||||
import { INSERT_NEW_PARTS_ORDERS } from "../../graphql/parts-orders.queries";
|
||||
import {
|
||||
INSERT_NEW_PARTS_ORDERS,
|
||||
QUERY_PARTS_ORDER_OEC,
|
||||
} from "../../graphql/parts-orders.queries";
|
||||
import { QUERY_ALL_VENDORS_FOR_ORDER } from "../../graphql/vendors.queries";
|
||||
import { insertAuditTrail } from "../../redux/application/application.actions";
|
||||
import { setEmailOptions } from "../../redux/email/email.actions";
|
||||
@@ -26,6 +29,7 @@ import { TemplateList } from "../../utils/TemplateConstants";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
import PartsOrderModalComponent from "./parts-order-modal.component";
|
||||
import axios from "axios";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser,
|
||||
@@ -52,7 +56,7 @@ export function PartsOrderModalContainer({
|
||||
insertAuditTrail,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const client = useApolloClient();
|
||||
const { visible, context, actions } = partsOrderModal;
|
||||
const {
|
||||
jobId,
|
||||
@@ -175,7 +179,7 @@ export function PartsOrderModalContainer({
|
||||
}
|
||||
|
||||
if (refetch) refetch();
|
||||
toggleModalVisible();
|
||||
|
||||
const Templates = TemplateList("partsorder", context);
|
||||
|
||||
if (sendType === "e") {
|
||||
@@ -215,7 +219,44 @@ export function PartsOrderModalContainer({
|
||||
{},
|
||||
"p"
|
||||
);
|
||||
} else if (sendType === "oec") {
|
||||
//Send to Partner OEC.
|
||||
try {
|
||||
const partsOrder = await client.query({
|
||||
query: QUERY_PARTS_ORDER_OEC,
|
||||
variables: {
|
||||
id: insertResult.data.insert_parts_orders.returning[0].id,
|
||||
},
|
||||
});
|
||||
console.log("🚀 ~ file: parts-order-modal.container.jsx ~ line 231 ~ handleFinish ~ partsOrder", partsOrder)
|
||||
|
||||
const oecResponse = await axios.post(
|
||||
"http://localhost:1337/oec/",
|
||||
|
||||
partsOrder.data.parts_orders_by_pk,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${await auth.currentUser.getIdToken()}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
console.log(
|
||||
"🚀 ~ file: parts-order-modal.container.jsx ~ line 232 ~ handleFinish ~ oecResponse",
|
||||
oecResponse
|
||||
);
|
||||
} catch (error) {
|
||||
console.log("Error OEC.", error);
|
||||
notification["error"]({
|
||||
message: t("parts_orders.errors.oec", {
|
||||
error: JSON.stringify(error.message),
|
||||
}),
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
toggleModalVisible();
|
||||
};
|
||||
|
||||
const initialValues = {
|
||||
|
||||
Reference in New Issue
Block a user