notify check for new case ref tempate and pref lang

This commit is contained in:
2026-03-09 14:10:30 +00:00
parent de5ee86cde
commit 6e3f7eeec1
2 changed files with 17 additions and 27 deletions
+1 -25
View File
@@ -1969,36 +1969,12 @@ export const sendEmail = async (
"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 {
const response = await axios.post("/api/email/notify", mailData);
return response.data;
} catch (error) {
consoleLogger(error); // Optional custom logging
throw error; // ✅ Ensure the calling function sees the error
throw error;
}
};
+16 -2
View File
@@ -25,11 +25,25 @@
* description: Failed
*/
import { consoleLogger } from "../../../actions";
import { consoleLogger, getPreferredLanguage } from "../../../actions";
export default async function ApiProxy(req, res) {
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;
const notifyClient = new NotifyClient(process.env.NOTIFY_API_KEY);
@@ -40,7 +54,7 @@ export default async function ApiProxy(req, res) {
notifyClient
.sendEmail(data.templateId, data.emailAddress, {
personalisation: data.personalisation,
reference: data.reference,
reference: data.reference
// emailReplyToId: emailReplyToId,
})
.then((response) => {