Added ability to generat PDF on test email page.
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
import { Button, Form, Input } from "antd";
|
import { Button, Form, Input, Switch } from "antd";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { setEmailOptions } from "../../redux/email/email.actions";
|
import { setEmailOptions } from "../../redux/email/email.actions";
|
||||||
import { selectCurrentUser } from "../../redux/user/user.selectors";
|
import { selectCurrentUser } from "../../redux/user/user.selectors";
|
||||||
|
import { GenerateDocument } from "../../utils/RenderTemplate";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
currentUser: selectCurrentUser,
|
currentUser: selectCurrentUser,
|
||||||
@@ -19,17 +20,16 @@ export function EmailTestComponent({ currentUser, setEmailOptions }) {
|
|||||||
|
|
||||||
const handleFinish = (values) => {
|
const handleFinish = (values) => {
|
||||||
console.log("values", values);
|
console.log("values", values);
|
||||||
setEmailOptions({
|
GenerateDocument(
|
||||||
messageOptions: {
|
{
|
||||||
to: currentUser.email || null,
|
|
||||||
},
|
|
||||||
template: {
|
|
||||||
name: values.key,
|
name: values.key,
|
||||||
variables: {
|
variables: {
|
||||||
id: values.id,
|
id: values.id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
{},
|
||||||
|
values.email ? "e" : "p"
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -64,6 +64,13 @@ export function EmailTestComponent({ currentUser, setEmailOptions }) {
|
|||||||
>
|
>
|
||||||
<Input />
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
name="email"
|
||||||
|
label="Generate as email?"
|
||||||
|
valuePropName="checked"
|
||||||
|
>
|
||||||
|
<Switch />
|
||||||
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
<Button onClick={() => form.submit()}>Execute</Button>
|
<Button onClick={() => form.submit()}>Execute</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -75,15 +75,15 @@ export default async function RenderTemplate(
|
|||||||
|
|
||||||
if (!renderAsHtml) {
|
if (!renderAsHtml) {
|
||||||
render.download();
|
render.download();
|
||||||
var html =
|
// var html =
|
||||||
"<html>" +
|
// "<html>" +
|
||||||
"<style>html,body {padding:0;margin:0;} iframe {width:100%;height:100%;border:0}</style>" +
|
// "<style>html,body {padding:0;margin:0;} iframe {width:100%;height:100%;border:0}</style>" +
|
||||||
"<body>" +
|
// "<body>" +
|
||||||
'<iframe type="application/pdf" src="' +
|
// '<iframe type="application/pdf" src="' +
|
||||||
render.toDataURI() +
|
// render.toDataURI() +
|
||||||
'"></iframe>' +
|
// '"></iframe>' +
|
||||||
"</body></html>";
|
// "</body></html>";
|
||||||
displayTemplateInWindowNoprint(html);
|
// displayTemplateInWindowNoprint(html);
|
||||||
} else {
|
} else {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
resolve(render.toString());
|
resolve(render.toString());
|
||||||
@@ -133,6 +133,6 @@ export const GenerateDocument = async (template, messageOptions, sendType) => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
displayTemplateInWindow(await RenderTemplate(template, bodyshop));
|
await RenderTemplate(template, bodyshop);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ exports.inlinecss = (req, res) => {
|
|||||||
|
|
||||||
inlineCssTool(html, { url: url })
|
inlineCssTool(html, { url: url })
|
||||||
.then((inlinedHtml) => {
|
.then((inlinedHtml) => {
|
||||||
|
console.log("Inline success.");
|
||||||
res.send(inlinedHtml);
|
res.send(inlinedHtml);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user