Added dates to render template & email test IO-636

This commit is contained in:
Patrick Fic
2021-02-04 16:21:11 -08:00
parent e90dc8a9ec
commit aa1f5c6b06
2 changed files with 49 additions and 51 deletions

View File

@@ -6,6 +6,8 @@ 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"; import { GenerateDocument } from "../../utils/RenderTemplate";
import DateTimePicker from "../form-date-time-picker/form-date-time-picker.component";
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
const mapStateToProps = createStructuredSelector({ const mapStateToProps = createStructuredSelector({
currentUser: selectCurrentUser, currentUser: selectCurrentUser,
@@ -24,7 +26,9 @@ export function EmailTestComponent({ currentUser, setEmailOptions }) {
{ {
name: values.key, name: values.key,
variables: { variables: {
id: values.id, ...(values.id ? { id: values.id } : {}),
...(values.start ? { start: values.start } : {}),
...(values.end ? { end: values.end } : {}),
}, },
}, },
{ {
@@ -49,6 +53,7 @@ export function EmailTestComponent({ currentUser, setEmailOptions }) {
], ],
}} }}
> >
<LayoutFormRow>
<Form.Item <Form.Item
name="to" name="to"
label="Recipients" label="Recipients"
@@ -72,16 +77,7 @@ export function EmailTestComponent({ currentUser, setEmailOptions }) {
> >
<Input /> <Input />
</Form.Item> </Form.Item>
<Form.Item <Form.Item name="id" label="Record ID">
name="id"
label="Record ID"
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<Input /> <Input />
</Form.Item> </Form.Item>
<Form.Item <Form.Item
@@ -91,6 +87,15 @@ export function EmailTestComponent({ currentUser, setEmailOptions }) {
> >
<Switch /> <Switch />
</Form.Item> </Form.Item>
</LayoutFormRow>
<LayoutFormRow>
<Form.Item name="start" label="Start Date">
<DateTimePicker />
</Form.Item>
<Form.Item name="end" label="End Date">
<DateTimePicker />
</Form.Item>
</LayoutFormRow>
</Form> </Form>
<Button onClick={() => form.submit()}>Execute</Button> <Button onClick={() => form.submit()}>Execute</Button>
</div> </div>

View File

@@ -13,14 +13,6 @@ export default async function RenderTemplate(
bodyshop, bodyshop,
renderAsHtml = false renderAsHtml = false
) { ) {
//Template Object
// {
// name: TemplateList().parts_order.key,
// variables: {
// id: insertResult.data.insert_parts_orders.returning[0].id,
// },
// },
//Query assets that match the template name. Must be in format <<templateName>>.query //Query assets that match the template name. Must be in format <<templateName>>.query
jsreport.headers["Authorization"] = jsreport.headers["Authorization"] =
@@ -67,6 +59,7 @@ export default async function RenderTemplate(
}, },
data: { data: {
...contextData, ...contextData,
...templateObject.variables,
headerpath: `/${bodyshop.imexshopid}/header.html`, headerpath: `/${bodyshop.imexshopid}/header.html`,
bodyshop: bodyshop, bodyshop: bodyshop,
}, },