feature/IO-3103-Ant5-Notifications
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { gql } from "@apollo/client";
|
||||
import jsreport from "@jsreport/browser-client";
|
||||
import { notification } from "antd";
|
||||
import axios from "axios";
|
||||
import _ from "lodash";
|
||||
import { auth } from "../firebase/firebase.utils";
|
||||
@@ -11,11 +10,13 @@ import cleanAxios from "./CleanAxios";
|
||||
import { TemplateList } from "./TemplateConstants";
|
||||
import { generateTemplate } from "./graphQLmodifier";
|
||||
import InstanceRenderManager from "./instanceRenderMgr";
|
||||
|
||||
const server = import.meta.env.VITE_APP_REPORTS_SERVER_URL;
|
||||
|
||||
jsreport.serverUrl = server;
|
||||
|
||||
let Templates;
|
||||
|
||||
export function GenerateTemplates() {
|
||||
//Required as a part of the transition to Vite.
|
||||
//Previous method had the template hash generating before translations loaded, resulting in empty files.
|
||||
@@ -27,7 +28,8 @@ export default async function RenderTemplate(
|
||||
bodyshop,
|
||||
renderAsHtml = false,
|
||||
renderAsExcel = false,
|
||||
renderAsText = false
|
||||
renderAsText = false,
|
||||
notification
|
||||
) {
|
||||
if (window.jsr3) {
|
||||
jsreport.serverUrl = "https://reports3.test.imex.online/";
|
||||
@@ -72,8 +74,14 @@ export default async function RenderTemplate(
|
||||
...contextData,
|
||||
...templateObject.variables,
|
||||
...templateObject.context,
|
||||
headerpath: `/${InstanceRenderManager({ imex: bodyshop.imexshopid, rome: bodyshop.imexshopid })}/header.html`,
|
||||
footerpath: `/${InstanceRenderManager({ imex: bodyshop.imexshopid, rome: bodyshop.imexshopid })}/footer.html`,
|
||||
headerpath: `/${InstanceRenderManager({
|
||||
imex: bodyshop.imexshopid,
|
||||
rome: bodyshop.imexshopid
|
||||
})}/header.html`,
|
||||
footerpath: `/${InstanceRenderManager({
|
||||
imex: bodyshop.imexshopid,
|
||||
rome: bodyshop.imexshopid
|
||||
})}/footer.html`,
|
||||
bodyshop: bodyshop,
|
||||
filters: templateObject?.filters,
|
||||
sorters: templateObject?.sorters,
|
||||
@@ -131,7 +139,7 @@ export default async function RenderTemplate(
|
||||
}
|
||||
}
|
||||
|
||||
export async function RenderTemplates(templateObjects, bodyshop, renderAsHtml = false) {
|
||||
export async function RenderTemplates(templateObjects, bodyshop, renderAsHtml = false, notification) {
|
||||
//Query assets that match the template name. Must be in format <<templateName>>.query
|
||||
let unsortedTemplatesAndData = [];
|
||||
let proms = [];
|
||||
@@ -259,7 +267,7 @@ export async function RenderTemplates(templateObjects, bodyshop, renderAsHtml =
|
||||
}
|
||||
}
|
||||
|
||||
export const GenerateDocument = async (template, messageOptions, sendType, jobid) => {
|
||||
export const GenerateDocument = async (template, messageOptions, sendType, jobid, notification) => {
|
||||
const bodyshop = store.getState().user.bodyshop;
|
||||
if (sendType === "e") {
|
||||
store.dispatch(
|
||||
@@ -273,17 +281,17 @@ export const GenerateDocument = async (template, messageOptions, sendType, jobid
|
||||
})
|
||||
);
|
||||
} else if (sendType === "x") {
|
||||
await RenderTemplate(template, bodyshop, false, true);
|
||||
await RenderTemplate(template, bodyshop, false, true, false, notification);
|
||||
} else if (sendType === "text") {
|
||||
await RenderTemplate(template, bodyshop, false, false, true);
|
||||
await RenderTemplate(template, bodyshop, false, false, true, notification);
|
||||
} else {
|
||||
await RenderTemplate(template, bodyshop);
|
||||
await RenderTemplate(template, bodyshop, false, false, false, notification);
|
||||
}
|
||||
};
|
||||
|
||||
export const GenerateDocuments = async (templates) => {
|
||||
export const GenerateDocuments = async (templates, notification) => {
|
||||
const bodyshop = store.getState().user.bodyshop;
|
||||
await RenderTemplates(templates, bodyshop);
|
||||
await RenderTemplates(templates, bodyshop, false, notification);
|
||||
};
|
||||
|
||||
export const fetchFilterData = async ({ name }) => {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import axios from "axios";
|
||||
import { notification } from "antd";
|
||||
|
||||
async function CriticalPartsScan(jobid) {
|
||||
async function CriticalPartsScan(jobid, notification) {
|
||||
try {
|
||||
await axios.post("/job/partsscan", { jobid });
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user