General gendoc function & reprint parts orders IO-411

This commit is contained in:
Patrick Fic
2021-01-14 16:40:16 -08:00
parent ffbe670499
commit 5a6991dad6
7 changed files with 146 additions and 117 deletions

View File

@@ -3,6 +3,9 @@ import jsreport from "jsreport-browser-client-dist";
import client from "../utils/GraphQLClient";
import axios from "axios";
import { auth } from "../firebase/firebase.utils";
import { TemplateList } from "./TemplateConstants";
import { store } from "../redux/store";
import { setEmailOptions } from "../redux/email/email.actions";
const server = process.env.REACT_APP_REPORTS_SERVER_URL;
jsreport.serverUrl = server;
@@ -120,3 +123,17 @@ export const displayTemplateInWindowNoprint = (html) => {
console.log("Unable to write to new window.", error);
}
};
export const GenerateDocument = async (template, messageOptions, sendType) => {
const bodyshop = store.getState().user.bodyshop;
if (sendType === "e") {
store.dispatch(
setEmailOptions({
messageOptions,
template,
})
);
} else {
displayTemplateInWindow(await RenderTemplate(template, bodyshop));
}
};