BOD-9 Added print format to parts order.
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
import { useApolloClient } from "@apollo/react-hooks";
|
||||
import { Modal, notification } from "antd";
|
||||
import axios from "axios";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { EmailSettings } from "../../utils/constants";
|
||||
import { toggleEmailOverlayVisible } from "../../redux/email/email.actions";
|
||||
import {
|
||||
selectEmailConfig,
|
||||
selectEmailVisible,
|
||||
} from "../../redux/email/email.selectors.js";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import { EmailSettings } from "../../utils/constants";
|
||||
import RenderTemplate from "../../utils/RenderTemplate";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
import EmailOverlayComponent from "./email-overlay.component";
|
||||
@@ -43,7 +42,6 @@ export function EmailOverlayContainer({
|
||||
...defaultEmailFrom,
|
||||
html: "",
|
||||
});
|
||||
const client = useApolloClient();
|
||||
|
||||
const handleOk = () => {
|
||||
//sendEmail(messageOptions);
|
||||
@@ -72,7 +70,7 @@ export function EmailOverlayContainer({
|
||||
|
||||
const render = async () => {
|
||||
setLoading(true);
|
||||
let html = await RenderTemplate(emailConfig.template, client, bodyshop);
|
||||
let html = await RenderTemplate(emailConfig.template, bodyshop);
|
||||
setMessageOptions({
|
||||
...emailConfig.messageOptions,
|
||||
...defaultEmailFrom,
|
||||
|
||||
@@ -11,10 +11,14 @@ import { QUERY_ALL_VENDORS_FOR_ORDER } from "../../graphql/vendors.queries";
|
||||
import { setEmailOptions } from "../../redux/email/email.actions";
|
||||
import { toggleModalVisible } from "../../redux/modals/modals.actions";
|
||||
import { selectPartsOrder } from "../../redux/modals/modals.selectors";
|
||||
import { selectBodyshop, selectCurrentUser } from "../../redux/user/user.selectors";
|
||||
import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
import PartsOrderModalComponent from "./parts-order-modal.component";
|
||||
import RenderTemplate from "../../utils/RenderTemplate";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser,
|
||||
@@ -127,6 +131,20 @@ export function PartsOrderModalContainer({
|
||||
},
|
||||
},
|
||||
});
|
||||
} else {
|
||||
RenderTemplate(
|
||||
{
|
||||
name: "parts_order_confirmation",
|
||||
variables: {
|
||||
id: r.data.insert_parts_orders.returning[0].id,
|
||||
},
|
||||
},
|
||||
|
||||
bodyshop
|
||||
).then((html) => {
|
||||
var newWin = window.open();
|
||||
newWin.document.write(html);
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { MailOutlined, PrinterOutlined } from "@ant-design/icons";
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { setEmailOptions } from "../../redux/email/email.actions";
|
||||
import { selectPrintCenter } from "../../redux/modals/modals.selectors";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import { MailOutlined, PrinterOutlined } from "@ant-design/icons";
|
||||
import RenderTemplate from "../../utils/RenderTemplate";
|
||||
import { useApolloClient } from "@apollo/react-hooks";
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
printCenterModal: selectPrintCenter,
|
||||
bodyshop: selectBodyshop,
|
||||
@@ -23,15 +22,13 @@ export function PrintCenterItemComponent({
|
||||
bodyshop,
|
||||
disabled,
|
||||
}) {
|
||||
const client = useApolloClient();
|
||||
|
||||
const renderToNewWindow = async () => {
|
||||
const html = await RenderTemplate(
|
||||
{
|
||||
name: item.key,
|
||||
variables: { id: id },
|
||||
},
|
||||
client,
|
||||
|
||||
bodyshop
|
||||
);
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import gql from "graphql-tag";
|
||||
import { QUERY_TEMPLATES_BY_NAME } from "../graphql/templates.queries";
|
||||
import axios from "axios";
|
||||
import { client } from "../App/App.container";
|
||||
|
||||
export default async function RenderTemplate(templateObject, client, bodyshop) {
|
||||
export default async function RenderTemplate(templateObject, bodyshop) {
|
||||
const { data: templateRecords } = await client.query({
|
||||
query: QUERY_TEMPLATES_BY_NAME,
|
||||
variables: { name: templateObject.name },
|
||||
|
||||
Reference in New Issue
Block a user