47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
import {MailOutlined, PrinterOutlined} from "@ant-design/icons";
|
|
import {Space, Spin} from "antd";
|
|
import React, {useState} from "react";
|
|
import {connect} from "react-redux";
|
|
import {createStructuredSelector} from "reselect";
|
|
import {setEmailOptions} from "../../redux/email/email.actions";
|
|
import {GenerateDocument} from "../../utils/RenderTemplate";
|
|
import {TemplateList} from "../../utils/TemplateConstants";
|
|
|
|
const mapStateToProps = createStructuredSelector({});
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
setEmailOptions: (e) => dispatch(setEmailOptions(e)),
|
|
});
|
|
|
|
export function ChatPrintButton({conversation}) {
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
const generateDocument = (type) => {
|
|
setLoading(true);
|
|
GenerateDocument(
|
|
{
|
|
name: TemplateList("messaging").conversation_list.key,
|
|
variables: {id: conversation.id},
|
|
},
|
|
{
|
|
subject: TemplateList("messaging").conversation_list.subject,
|
|
},
|
|
type,
|
|
conversation.id
|
|
).catch(e => {
|
|
console.warn('Something went wrong generating a document.');
|
|
});
|
|
setLoading(false);
|
|
}
|
|
|
|
return (
|
|
<Space wrap>
|
|
<PrinterOutlined onClick={() => generateDocument('p')}/>
|
|
<MailOutlined onClick={() => generateDocument('e')}/>
|
|
{loading && <Spin/>}
|
|
</Space>
|
|
);
|
|
}
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(ChatPrintButton);
|