feature/IO-2962-Task-Email-Footer-Timestamps - Localize Date in Task Email Footer
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -10,7 +10,7 @@ const logger = require("../utils/logger");
|
||||
const client = require("../graphql-client/graphql-client").client;
|
||||
const queries = require("../graphql-client/queries");
|
||||
const generateEmailTemplate = require("./generateTemplate");
|
||||
const moment = require("moment");
|
||||
const moment = require("moment-timezone");
|
||||
const { taskEmailQueue } = require("./tasksEmailsQueue");
|
||||
|
||||
const ses = new aws.SES({
|
||||
@@ -108,12 +108,13 @@ const getEndpoints = (bodyshop) =>
|
||||
: "https://romeonline.io"
|
||||
});
|
||||
|
||||
const generateTemplateArgs = (title, priority, description, dueDate, bodyshop, job, taskId) => {
|
||||
const generateTemplateArgs = (title, priority, description, dueDate, bodyshop, job, taskId, dateLine) => {
|
||||
const endPoints = getEndpoints(bodyshop);
|
||||
return {
|
||||
header: title,
|
||||
subHeader: `Body Shop: ${bodyshop.shopname} | Priority: ${formatPriority(priority)} ${formatDate(dueDate)}`,
|
||||
body: `Reference: ${job.ro_number || "N/A"} | ${job.ownr_co_nm ? job.ownr_co_nm : `${job.ownr_fn || ""} ${job.ownr_ln || ""}`.trim()} | ${`${job.v_model_yr || ""} ${job.v_make_desc || ""} ${job.v_model_desc || ""}`.trim()}<br>${description ? description.concat("<br>") : ""}<a href="${endPoints}/manage/tasks/alltasks?taskid=${taskId}">View this task.</a>`
|
||||
body: `Reference: ${job.ro_number || "N/A"} | ${job.ownr_co_nm ? job.ownr_co_nm : `${job.ownr_fn || ""} ${job.ownr_ln || ""}`.trim()} | ${`${job.v_model_yr || ""} ${job.v_make_desc || ""} ${job.v_model_desc || ""}`.trim()}<br>${description ? description.concat("<br>") : ""}<a href="${endPoints}/manage/tasks/alltasks?taskid=${taskId}">View this task.</a>`,
|
||||
dateLine
|
||||
};
|
||||
};
|
||||
|
||||
@@ -178,6 +179,8 @@ const taskAssignedEmail = async (req, res) => {
|
||||
id: newTask.id
|
||||
});
|
||||
|
||||
const dateLine = moment().tz(tasks_by_pk.bodyshop.timezone).format("M/DD/YYYY @ hh:mm a");
|
||||
|
||||
sendMail(
|
||||
"assigned",
|
||||
tasks_by_pk.assigned_to_employee.user_email,
|
||||
@@ -190,7 +193,8 @@ const taskAssignedEmail = async (req, res) => {
|
||||
newTask.due_date,
|
||||
tasks_by_pk.bodyshop,
|
||||
tasks_by_pk.job,
|
||||
newTask.id
|
||||
newTask.id,
|
||||
dateLine
|
||||
)
|
||||
),
|
||||
null,
|
||||
@@ -247,7 +251,7 @@ const tasksRemindEmail = async (req, res) => {
|
||||
const fromEmails = InstanceManager({
|
||||
imex: "ImEX Online <noreply@imex.online>",
|
||||
rome:
|
||||
tasksRequest?.tasks[0].bodyshop.convenient_company === "promanager"
|
||||
tasksRequest?.tasks[0].bodyshop.convenient_company === "promanager"
|
||||
? "ProManager <noreply@promanager.web-est.com>"
|
||||
: "Rome Online <noreply@romeonline.io>"
|
||||
});
|
||||
@@ -259,6 +263,8 @@ const tasksRemindEmail = async (req, res) => {
|
||||
|
||||
const taskIds = groupedTasks[recipient.email].map((task) => task.id);
|
||||
|
||||
const dateLine = moment().tz(tasksRequest?.tasks[0].bodyshop.timezone).format("M/DD/YYYY @ hh:mm a");
|
||||
|
||||
// There is only the one email to send to this author.
|
||||
if (recipient.count === 1) {
|
||||
const onlyTask = groupedTasks[recipient.email][0];
|
||||
@@ -274,7 +280,8 @@ const tasksRemindEmail = async (req, res) => {
|
||||
onlyTask.due_date,
|
||||
onlyTask.bodyshop,
|
||||
onlyTask.job,
|
||||
onlyTask.id
|
||||
onlyTask.id,
|
||||
dateLine
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -283,7 +290,7 @@ const tasksRemindEmail = async (req, res) => {
|
||||
const endPoints = InstanceManager({
|
||||
imex: process.env?.NODE_ENV === "test" ? "https://test.imex.online" : "https://imex.online",
|
||||
rome:
|
||||
tasksRequest?.tasks[0].bodyshop.convenient_company === "promanager"
|
||||
tasksRequest?.tasks[0].bodyshop.convenient_company === "promanager"
|
||||
? process.env?.NODE_ENV === "test"
|
||||
? "https//test.promanager.web-est.com"
|
||||
: "https://promanager.web-est.com"
|
||||
@@ -297,6 +304,7 @@ const tasksRemindEmail = async (req, res) => {
|
||||
emailData.html = generateEmailTemplate({
|
||||
header: `${allTasks.length} Tasks require your attention`,
|
||||
subHeader: `Please click on the Tasks below to view the Task.`,
|
||||
dateLine,
|
||||
body: `<ul>
|
||||
${allTasks
|
||||
.map((task) =>
|
||||
|
||||
Reference in New Issue
Block a user