Further work on async email modal. Correctly sending basic emails.
This commit is contained in:
@@ -722,6 +722,63 @@
|
||||
</folder_node>
|
||||
</children>
|
||||
</folder_node>
|
||||
<folder_node>
|
||||
<name>emails</name>
|
||||
<children>
|
||||
<folder_node>
|
||||
<name>errors</name>
|
||||
<children>
|
||||
<concept_node>
|
||||
<name>notsent</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
</children>
|
||||
</folder_node>
|
||||
<folder_node>
|
||||
<name>successes</name>
|
||||
<children>
|
||||
<concept_node>
|
||||
<name>sent</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>es-MX</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
<translation>
|
||||
<language>fr-CA</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
</children>
|
||||
</folder_node>
|
||||
</children>
|
||||
</folder_node>
|
||||
<folder_node>
|
||||
<name>employees</name>
|
||||
<children>
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
import { Button, Modal } from "antd";
|
||||
import { Button, Modal, notification } from "antd";
|
||||
import axios from "axios";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useLazyQuery } from "react-apollo";
|
||||
import { renderEmail } from "react-html-email";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import {
|
||||
sendEmail,
|
||||
toggleEmailOverlayVisible
|
||||
} from "../../redux/email/email.actions";
|
||||
import {
|
||||
selectEmailConfig,
|
||||
selectEmailVisible
|
||||
} from "../../redux/email/email.selectors.js";
|
||||
import { toggleEmailOverlayVisible } from "../../redux/email/email.actions";
|
||||
import { selectEmailConfig, selectEmailVisible } from "../../redux/email/email.selectors.js";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
import EmailOverlayComponent from "./email-overlay.component";
|
||||
|
||||
@@ -20,18 +16,13 @@ const mapStateToProps = createStructuredSelector({
|
||||
emailConfig: selectEmailConfig
|
||||
});
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
toggleEmailOverlayVisible: () => dispatch(toggleEmailOverlayVisible()),
|
||||
sendEmail: email => dispatch(sendEmail(email))
|
||||
toggleEmailOverlayVisible: () => dispatch(toggleEmailOverlayVisible())
|
||||
});
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(function SendEmail({
|
||||
emailConfig,
|
||||
modalVisible,
|
||||
sendEmail,
|
||||
toggleEmailOverlayVisible
|
||||
}) {
|
||||
)(function SendEmail({ emailConfig, modalVisible, toggleEmailOverlayVisible }) {
|
||||
const { t } = useTranslation();
|
||||
const [messageOptions, setMessageOptions] = useState(
|
||||
emailConfig.messageOptions
|
||||
);
|
||||
@@ -57,7 +48,6 @@ export default connect(
|
||||
}
|
||||
|
||||
if (data && !messageOptions.html && emailConfig.template) {
|
||||
//console.log(ReactDOMServer.renderToStaticMarkup(<Template data={data} />));
|
||||
setMessageOptions({
|
||||
...messageOptions,
|
||||
//html: ReactDOMServer.renderToStaticMarkup(<Template data={data} />)
|
||||
@@ -66,8 +56,20 @@ export default connect(
|
||||
}
|
||||
|
||||
const handleOk = () => {
|
||||
sendEmail("Clicked OK");
|
||||
toggleEmailOverlayVisible();
|
||||
//sendEmail(messageOptions);
|
||||
axios
|
||||
.post("/sendemail", messageOptions)
|
||||
.then(response => {
|
||||
console.log(JSON.stringify(response));
|
||||
notification["success"]({ message: t("emails.successes.sent") });
|
||||
toggleEmailOverlayVisible();
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(JSON.stringify(error));
|
||||
notification["error"]({
|
||||
message: t("emails.errors.notsent", { message: error.message })
|
||||
});
|
||||
});
|
||||
};
|
||||
const handleConfigChange = event => {
|
||||
const { name, value } = event.target;
|
||||
|
||||
@@ -72,12 +72,9 @@ export default function Manage({ match }) {
|
||||
fallback={
|
||||
<LoadingSpinner message={t("general.labels.loadingapp")} />
|
||||
}>
|
||||
<div>
|
||||
DELETE THESE
|
||||
<Test />
|
||||
<EmailOverlayContainer />
|
||||
</div>
|
||||
|
||||
DELETE THIS
|
||||
<Test />
|
||||
<EmailOverlayContainer />
|
||||
<Route exact path={`${match.path}`} component={ManageRootPage} />
|
||||
<Route exact path={`${match.path}/jobs`} component={JobsPage} />
|
||||
<Route
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { all, call, put, takeLatest } from "redux-saga/effects";
|
||||
import { sendEmailFailure, sendEmailSuccess } from "./email.actions";
|
||||
import EmailActionTypes from "./email.types";
|
||||
import axios from "axios";
|
||||
|
||||
export function* onSendEmail() {
|
||||
yield takeLatest(EmailActionTypes.SEND_EMAIL, sendEmail);
|
||||
@@ -8,10 +9,10 @@ export function* onSendEmail() {
|
||||
export function* sendEmail(payload) {
|
||||
try {
|
||||
console.log("Sending thta email", payload);
|
||||
// // axios.post("/sendemail", emailConfig).then(response => {
|
||||
// alert(JSON.stringify(response));
|
||||
// });
|
||||
yield put(sendEmailSuccess());
|
||||
axios.post("/sendemail", payload).then(response => {
|
||||
console.log(JSON.stringify(response));
|
||||
put(sendEmailSuccess());
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("Error in sendEmail saga.");
|
||||
yield put(sendEmailFailure(error.message));
|
||||
|
||||
@@ -67,6 +67,14 @@
|
||||
"insert": "Uploaded document successfully. "
|
||||
}
|
||||
},
|
||||
"emails": {
|
||||
"errors": {
|
||||
"notsent": "Email not sent. Error encountered while sending {{message}}"
|
||||
},
|
||||
"successes": {
|
||||
"sent": "Email sent successfully."
|
||||
}
|
||||
},
|
||||
"employees": {
|
||||
"actions": {
|
||||
"new": "New Employee"
|
||||
|
||||
@@ -67,6 +67,14 @@
|
||||
"insert": "Documento cargado con éxito."
|
||||
}
|
||||
},
|
||||
"emails": {
|
||||
"errors": {
|
||||
"notsent": "Correo electrónico no enviado Se encontró un error al enviar {{message}}"
|
||||
},
|
||||
"successes": {
|
||||
"sent": "Correo electrónico enviado con éxito."
|
||||
}
|
||||
},
|
||||
"employees": {
|
||||
"actions": {
|
||||
"new": "Nuevo empleado"
|
||||
|
||||
@@ -67,6 +67,14 @@
|
||||
"insert": "Document téléchargé avec succès."
|
||||
}
|
||||
},
|
||||
"emails": {
|
||||
"errors": {
|
||||
"notsent": "Courriel non envoyé. Erreur rencontrée lors de l'envoi de {{message}}"
|
||||
},
|
||||
"successes": {
|
||||
"sent": "E-mail envoyé avec succès."
|
||||
}
|
||||
},
|
||||
"employees": {
|
||||
"actions": {
|
||||
"new": "Nouvel employé"
|
||||
|
||||
Reference in New Issue
Block a user