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 client = require("../graphql-client/graphql-client").client;
|
||||||
const queries = require("../graphql-client/queries");
|
const queries = require("../graphql-client/queries");
|
||||||
const generateEmailTemplate = require("./generateTemplate");
|
const generateEmailTemplate = require("./generateTemplate");
|
||||||
const moment = require("moment");
|
const moment = require("moment-timezone");
|
||||||
const { taskEmailQueue } = require("./tasksEmailsQueue");
|
const { taskEmailQueue } = require("./tasksEmailsQueue");
|
||||||
|
|
||||||
const ses = new aws.SES({
|
const ses = new aws.SES({
|
||||||
@@ -108,12 +108,13 @@ const getEndpoints = (bodyshop) =>
|
|||||||
: "https://romeonline.io"
|
: "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);
|
const endPoints = getEndpoints(bodyshop);
|
||||||
return {
|
return {
|
||||||
header: title,
|
header: title,
|
||||||
subHeader: `Body Shop: ${bodyshop.shopname} | Priority: ${formatPriority(priority)} ${formatDate(dueDate)}`,
|
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
|
id: newTask.id
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const dateLine = moment().tz(tasks_by_pk.bodyshop.timezone).format("M/DD/YYYY @ hh:mm a");
|
||||||
|
|
||||||
sendMail(
|
sendMail(
|
||||||
"assigned",
|
"assigned",
|
||||||
tasks_by_pk.assigned_to_employee.user_email,
|
tasks_by_pk.assigned_to_employee.user_email,
|
||||||
@@ -190,7 +193,8 @@ const taskAssignedEmail = async (req, res) => {
|
|||||||
newTask.due_date,
|
newTask.due_date,
|
||||||
tasks_by_pk.bodyshop,
|
tasks_by_pk.bodyshop,
|
||||||
tasks_by_pk.job,
|
tasks_by_pk.job,
|
||||||
newTask.id
|
newTask.id,
|
||||||
|
dateLine
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
null,
|
null,
|
||||||
@@ -247,7 +251,7 @@ const tasksRemindEmail = async (req, res) => {
|
|||||||
const fromEmails = InstanceManager({
|
const fromEmails = InstanceManager({
|
||||||
imex: "ImEX Online <noreply@imex.online>",
|
imex: "ImEX Online <noreply@imex.online>",
|
||||||
rome:
|
rome:
|
||||||
tasksRequest?.tasks[0].bodyshop.convenient_company === "promanager"
|
tasksRequest?.tasks[0].bodyshop.convenient_company === "promanager"
|
||||||
? "ProManager <noreply@promanager.web-est.com>"
|
? "ProManager <noreply@promanager.web-est.com>"
|
||||||
: "Rome Online <noreply@romeonline.io>"
|
: "Rome Online <noreply@romeonline.io>"
|
||||||
});
|
});
|
||||||
@@ -259,6 +263,8 @@ const tasksRemindEmail = async (req, res) => {
|
|||||||
|
|
||||||
const taskIds = groupedTasks[recipient.email].map((task) => task.id);
|
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.
|
// There is only the one email to send to this author.
|
||||||
if (recipient.count === 1) {
|
if (recipient.count === 1) {
|
||||||
const onlyTask = groupedTasks[recipient.email][0];
|
const onlyTask = groupedTasks[recipient.email][0];
|
||||||
@@ -274,7 +280,8 @@ const tasksRemindEmail = async (req, res) => {
|
|||||||
onlyTask.due_date,
|
onlyTask.due_date,
|
||||||
onlyTask.bodyshop,
|
onlyTask.bodyshop,
|
||||||
onlyTask.job,
|
onlyTask.job,
|
||||||
onlyTask.id
|
onlyTask.id,
|
||||||
|
dateLine
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -283,7 +290,7 @@ const tasksRemindEmail = async (req, res) => {
|
|||||||
const endPoints = InstanceManager({
|
const endPoints = InstanceManager({
|
||||||
imex: process.env?.NODE_ENV === "test" ? "https://test.imex.online" : "https://imex.online",
|
imex: process.env?.NODE_ENV === "test" ? "https://test.imex.online" : "https://imex.online",
|
||||||
rome:
|
rome:
|
||||||
tasksRequest?.tasks[0].bodyshop.convenient_company === "promanager"
|
tasksRequest?.tasks[0].bodyshop.convenient_company === "promanager"
|
||||||
? process.env?.NODE_ENV === "test"
|
? process.env?.NODE_ENV === "test"
|
||||||
? "https//test.promanager.web-est.com"
|
? "https//test.promanager.web-est.com"
|
||||||
: "https://promanager.web-est.com"
|
: "https://promanager.web-est.com"
|
||||||
@@ -297,6 +304,7 @@ const tasksRemindEmail = async (req, res) => {
|
|||||||
emailData.html = generateEmailTemplate({
|
emailData.html = generateEmailTemplate({
|
||||||
header: `${allTasks.length} Tasks require your attention`,
|
header: `${allTasks.length} Tasks require your attention`,
|
||||||
subHeader: `Please click on the Tasks below to view the Task.`,
|
subHeader: `Please click on the Tasks below to view the Task.`,
|
||||||
|
dateLine,
|
||||||
body: `<ul>
|
body: `<ul>
|
||||||
${allTasks
|
${allTasks
|
||||||
.map((task) =>
|
.map((task) =>
|
||||||
|
|||||||
@@ -2489,6 +2489,7 @@ exports.QUERY_REMIND_TASKS = `
|
|||||||
bodyshop {
|
bodyshop {
|
||||||
shopname
|
shopname
|
||||||
convenient_company
|
convenient_company
|
||||||
|
timezone
|
||||||
}
|
}
|
||||||
bodyshopid
|
bodyshopid
|
||||||
}
|
}
|
||||||
@@ -2512,6 +2513,7 @@ query QUERY_TASK_BY_ID($id: uuid!) {
|
|||||||
bodyshop{
|
bodyshop{
|
||||||
shopname
|
shopname
|
||||||
convenient_company
|
convenient_company
|
||||||
|
timezone
|
||||||
}
|
}
|
||||||
job{
|
job{
|
||||||
ro_number
|
ro_number
|
||||||
|
|||||||
Reference in New Issue
Block a user