Merged PR 2154: notify check for new case ref tempate and pref lang
notify check for new case ref tempate and pref lang Related work items: #21722, #21726
This commit is contained in:
+1
-25
@@ -1969,36 +1969,12 @@ export const sendEmail = async (
|
|||||||
"personalisation": personalisation
|
"personalisation": personalisation
|
||||||
};
|
};
|
||||||
|
|
||||||
//console.log(
|
|
||||||
// "hwewwew: ",
|
|
||||||
// templateId,
|
|
||||||
// emailAddress,
|
|
||||||
// personalisation,
|
|
||||||
// reference
|
|
||||||
// );
|
|
||||||
// var queryUrl = "/api/email/notify";
|
|
||||||
|
|
||||||
// var config = {
|
|
||||||
// method: "post",
|
|
||||||
// url: queryUrl,
|
|
||||||
// data: mailData,
|
|
||||||
// };
|
|
||||||
|
|
||||||
// return axios(config)
|
|
||||||
// .then((res) => {
|
|
||||||
// //console.log("posted ", res.data);
|
|
||||||
// return res.data;
|
|
||||||
// })
|
|
||||||
// .catch((error) => {
|
|
||||||
// consoleLogger(error);
|
|
||||||
// });
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.post("/api/email/notify", mailData);
|
const response = await axios.post("/api/email/notify", mailData);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
consoleLogger(error); // Optional custom logging
|
consoleLogger(error); // Optional custom logging
|
||||||
throw error; // ✅ Ensure the calling function sees the error
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -25,11 +25,25 @@
|
|||||||
* description: Failed
|
* description: Failed
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { consoleLogger } from "../../../actions";
|
import { consoleLogger, getPreferredLanguage } from "../../../actions";
|
||||||
|
|
||||||
export default async function ApiProxy(req, res) {
|
export default async function ApiProxy(req, res) {
|
||||||
var data = req.body;
|
var data = req.body;
|
||||||
|
|
||||||
|
if (data?.reference === "PEDW-NEW-CASEREF") {
|
||||||
|
try {
|
||||||
|
const prefLang = await getPreferredLanguage(data.emailAddress);
|
||||||
|
const preferredLanguage =
|
||||||
|
prefLang?.value?.[0]?.pinswg_preferredlanguage;
|
||||||
|
|
||||||
|
if (preferredLanguage === 846040000) {
|
||||||
|
data.templateId = "d2d9d0dc-e5d4-4da5-9156-775521d69c5c";
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
consoleLogger(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var NotifyClient = require("notifications-node-client").NotifyClient;
|
var NotifyClient = require("notifications-node-client").NotifyClient;
|
||||||
|
|
||||||
const notifyClient = new NotifyClient(process.env.NOTIFY_API_KEY);
|
const notifyClient = new NotifyClient(process.env.NOTIFY_API_KEY);
|
||||||
@@ -40,7 +54,7 @@ export default async function ApiProxy(req, res) {
|
|||||||
notifyClient
|
notifyClient
|
||||||
.sendEmail(data.templateId, data.emailAddress, {
|
.sendEmail(data.templateId, data.emailAddress, {
|
||||||
personalisation: data.personalisation,
|
personalisation: data.personalisation,
|
||||||
reference: data.reference,
|
reference: data.reference
|
||||||
// emailReplyToId: emailReplyToId,
|
// emailReplyToId: emailReplyToId,
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user