80 lines
2.0 KiB
JavaScript
80 lines
2.0 KiB
JavaScript
import { Button, Form, Input, Switch } from "antd";
|
|
import React from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { connect } from "react-redux";
|
|
import { createStructuredSelector } from "reselect";
|
|
import { setEmailOptions } from "../../redux/email/email.actions";
|
|
import { selectCurrentUser } from "../../redux/user/user.selectors";
|
|
import { GenerateDocument } from "../../utils/RenderTemplate";
|
|
|
|
const mapStateToProps = createStructuredSelector({
|
|
currentUser: selectCurrentUser,
|
|
});
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
setEmailOptions: (e) => dispatch(setEmailOptions(e)),
|
|
});
|
|
|
|
export function EmailTestComponent({ currentUser, setEmailOptions }) {
|
|
const [form] = Form.useForm();
|
|
const { t } = useTranslation();
|
|
|
|
const handleFinish = (values) => {
|
|
console.log("values", values);
|
|
GenerateDocument(
|
|
{
|
|
name: values.key,
|
|
variables: {
|
|
id: values.id,
|
|
},
|
|
},
|
|
{},
|
|
values.email ? "e" : "p"
|
|
);
|
|
};
|
|
|
|
return (
|
|
<div>
|
|
<Form
|
|
onFinish={handleFinish}
|
|
autoComplete={"off"}
|
|
layout="vertical"
|
|
form={form}
|
|
>
|
|
<Form.Item
|
|
name="key"
|
|
label="Template Key"
|
|
rules={[
|
|
{
|
|
required: true,
|
|
message: t("general.validation.required"),
|
|
},
|
|
]}
|
|
>
|
|
<Input />
|
|
</Form.Item>
|
|
<Form.Item
|
|
name="id"
|
|
label="Record ID"
|
|
rules={[
|
|
{
|
|
required: true,
|
|
message: t("general.validation.required"),
|
|
},
|
|
]}
|
|
>
|
|
<Input />
|
|
</Form.Item>
|
|
<Form.Item
|
|
name="email"
|
|
label="Generate as email?"
|
|
valuePropName="checked"
|
|
>
|
|
<Switch />
|
|
</Form.Item>
|
|
</Form>
|
|
<Button onClick={() => form.submit()}>Execute</Button>
|
|
</div>
|
|
);
|
|
}
|
|
export default connect(mapStateToProps, mapDispatchToProps)(EmailTestComponent);
|