BOD-34 Moved template rendering to utility class. Added basic config for some estimate reports.
This commit is contained in:
@@ -3,9 +3,13 @@ import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { setEmailOptions } from "../../redux/email/email.actions";
|
||||
import { selectPrintCenter } from "../../redux/modals/modals.selectors";
|
||||
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import { MailOutlined, PrinterOutlined } from "@ant-design/icons";
|
||||
import RenderTemplate from "../../utils/RenderTemplate";
|
||||
import { useApolloClient } from "@apollo/react-hooks";
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
printCenterModal: selectPrintCenter,
|
||||
bodyshop: selectBodyshop,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setEmailOptions: (e) => dispatch(setEmailOptions(e)),
|
||||
@@ -15,8 +19,46 @@ export function PrintCenterItemComponent({
|
||||
printCenterModal,
|
||||
setEmailOptions,
|
||||
item,
|
||||
id,
|
||||
bodyshop,
|
||||
disabled,
|
||||
}) {
|
||||
return <li>{item.title}</li>;
|
||||
const client = useApolloClient();
|
||||
|
||||
const renderToNewWindow = async () => {
|
||||
const html = await RenderTemplate(
|
||||
{
|
||||
name: item.key,
|
||||
variables: { id: id },
|
||||
},
|
||||
client,
|
||||
bodyshop
|
||||
);
|
||||
|
||||
var newWin = window.open();
|
||||
newWin.document.write(html);
|
||||
};
|
||||
|
||||
if (disabled) return <li className='print-center-item'>{item.title} </li>;
|
||||
return (
|
||||
<li className='print-center-item'>
|
||||
{item.title}
|
||||
<PrinterOutlined onClick={renderToNewWindow} />
|
||||
<MailOutlined
|
||||
onClick={() => {
|
||||
setEmailOptions({
|
||||
messageOptions: {
|
||||
Subject: "TODO FIX ME",
|
||||
},
|
||||
template: {
|
||||
name: item.key,
|
||||
variables: { id: id },
|
||||
},
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
|
||||
Reference in New Issue
Block a user