diff --git a/client/package.json b/client/package.json index bd23011dc..53b892548 100644 --- a/client/package.json +++ b/client/package.json @@ -4,6 +4,8 @@ "private": true, "proxy": "https://localhost:5000", "dependencies": { + "@ckeditor/ckeditor5-build-classic": "^16.0.0", + "@ckeditor/ckeditor5-react": "^2.1.0", "antd": "^3.26.8", "apollo-boost": "^0.4.4", "apollo-link-context": "^1.0.19", @@ -23,6 +25,7 @@ "react-big-calendar": "^0.23.0", "react-chartjs-2": "^2.9.0", "react-dom": "^16.12.0", + "react-html-email": "^3.0.0", "react-i18next": "^11.3.1", "react-icons": "^3.9.0", "react-image-file-resizer": "^0.2.1", diff --git a/client/src/components/send-email-button/send-email-button.component.jsx b/client/src/components/send-email-button/send-email-button.component.jsx new file mode 100644 index 000000000..86187363d --- /dev/null +++ b/client/src/components/send-email-button/send-email-button.component.jsx @@ -0,0 +1,46 @@ +import React from "react"; +import { Input } from "antd"; +import CKEditor from "@ckeditor/ckeditor5-react"; +import ClassicEditor from "@ckeditor/ckeditor5-build-classic"; + +export default function SendEmailButtonComponent({ + emailConfig, + handleConfigChange, + handleHtmlChange +}) { + return ( +
+ THis is where the text editing will happen To + + CC + + Subject + + { + // You can store the "editor" and use when it is needed. + console.log("Editor is ready to use!", editor); + }} + onChange={(event, editor) => { + const data = editor.getData(); + console.log({ event, editor, data }); + handleHtmlChange(data); + }} + /> +
+ ); +} diff --git a/client/src/components/send-email-button/send-email-button.container.jsx b/client/src/components/send-email-button/send-email-button.container.jsx new file mode 100644 index 000000000..23be75fb3 --- /dev/null +++ b/client/src/components/send-email-button/send-email-button.container.jsx @@ -0,0 +1,72 @@ +import { Button, Modal } from "antd"; +import axios from "axios"; +import React, { useState } from "react"; +import { useQuery } from "react-apollo"; +//Message options has the to & from details +//Query Config is what can get popped into UseQuery(QUERY_NAME, {variables: {vars}, fetchonly}) +//Template Which template should be used to send the email. +import ReactDOMServer from "react-dom/server"; +import { renderEmail } from "react-html-email"; +import LoadingSpinner from "../loading-spinner/loading-spinner.component"; +import SendEmailButtonComponent from "./send-email-button.component"; +export default function SendEmail({ + MessageOptions, + QueryConfig, + Template, + ...otherProps +}) { + const [modalVisible, setModalVisible] = useState(false); + const [emailConfig, setEmailConfig] = useState({ ...MessageOptions }); + const [gqlQuery, vars] = QueryConfig; + + const { loading, data } = useQuery(gqlQuery, { + ...vars, + fetchPolicy: "network-only", + skip: !modalVisible + }); + if (data && !emailConfig.html) { + console.log(ReactDOMServer.renderToStaticMarkup(