IO-2667 Tasks Email Generation
Signed-off-by: Allan Carr <allan.carr@thinkimex.com>
This commit is contained in:
@@ -99,14 +99,16 @@ const formatPriority = (priority) => {
|
|||||||
* @param priority
|
* @param priority
|
||||||
* @param description
|
* @param description
|
||||||
* @param dueDate
|
* @param dueDate
|
||||||
|
* @param bodyshop
|
||||||
|
* @param job
|
||||||
* @param taskId
|
* @param taskId
|
||||||
* @returns {{header, body: string, subHeader: string}}
|
* @returns {{header, body: string, subHeader: string}}
|
||||||
*/
|
*/
|
||||||
const generateTemplateArgs = (title, priority, description, dueDate, taskId) => {
|
const generateTemplateArgs = (title, priority, description, dueDate, bodyshop, job, taskId) => {
|
||||||
return {
|
return {
|
||||||
header: title,
|
header: title,
|
||||||
subHeader: `Priority: ${formatPriority(priority)} ${formatDate(dueDate)}`,
|
subHeader: `Body Shop: ${bodyshop.shopname} | Priority: ${formatPriority(priority)} ${formatDate(dueDate)}`,
|
||||||
body: `${description || ""}<br><a href="${endPoints}/manage/tasks/alltasks?taskid=${taskId}">View this task.</a>`
|
body: `Reference: ${job.ro_number} | ${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 + "<br>" : ""}<a href="${endPoints}/manage/tasks/alltasks?taskid=${taskId}">View this task.</a>`
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -175,7 +177,15 @@ const taskAssignedEmail = async (req, res) => {
|
|||||||
user_email,
|
user_email,
|
||||||
`A ${formatPriority(newTask.priority)} priority task has been ${dirty ? "reassigned to" : "created for"} you - ${newTask.title}`,
|
`A ${formatPriority(newTask.priority)} priority task has been ${dirty ? "reassigned to" : "created for"} you - ${newTask.title}`,
|
||||||
generateEmailTemplate(
|
generateEmailTemplate(
|
||||||
generateTemplateArgs(newTask.title, newTask.priority, newTask.description, newTask.due_date, newTask.id)
|
generateTemplateArgs(
|
||||||
|
newTask.title,
|
||||||
|
newTask.priority,
|
||||||
|
newTask.description,
|
||||||
|
newTask.due_date,
|
||||||
|
newTask.bodyshop,
|
||||||
|
newTask.job,
|
||||||
|
newTask.id
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -240,7 +250,15 @@ const tasksRemindEmail = async (req, res) => {
|
|||||||
`New ${formatPriority(onlyTask.priority)} Priority Task Reminder - ${onlyTask.title} ${onlyTask.due_date ? `- ${formatDate(onlyTask.due_date)}` : ""}`.trim();
|
`New ${formatPriority(onlyTask.priority)} Priority Task Reminder - ${onlyTask.title} ${onlyTask.due_date ? `- ${formatDate(onlyTask.due_date)}` : ""}`.trim();
|
||||||
|
|
||||||
emailData.html = generateEmailTemplate(
|
emailData.html = generateEmailTemplate(
|
||||||
generateTemplateArgs(onlyTask.title, onlyTask.priority, onlyTask.description, onlyTask.due_date, onlyTask.id)
|
generateTemplateArgs(
|
||||||
|
onlyTask.title,
|
||||||
|
onlyTask.priority,
|
||||||
|
onlyTask.description,
|
||||||
|
onlyTask.due_date,
|
||||||
|
onlyTask.bodyshop,
|
||||||
|
onlyTask.job,
|
||||||
|
onlyTask.id
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// There are multiple emails to send to this author.
|
// There are multiple emails to send to this author.
|
||||||
@@ -253,7 +271,7 @@ const tasksRemindEmail = async (req, res) => {
|
|||||||
body: `<ul>
|
body: `<ul>
|
||||||
${allTasks
|
${allTasks
|
||||||
.map((task) =>
|
.map((task) =>
|
||||||
`<li><a href="${endPoints}/manage/tasks/alltasks?taskid=${task.id}">${task.title} - Priority: ${formatPriority(task.priority)} ${task.due_date ? `${formatDate(task.due_date)}` : ""}</a></li>`.trim()
|
`<li><a href="${endPoints}/manage/tasks/alltasks?taskid=${task.id}">${task.title} - Priority: ${formatPriority(task.priority)} ${task.due_date ? `${formatDate(task.due_date)}` : ""} | Bodyshop: ${task.bodyshop.shopname}</a></li>`.trim()
|
||||||
)
|
)
|
||||||
.join("")}
|
.join("")}
|
||||||
</ul>`
|
</ul>`
|
||||||
|
|||||||
@@ -2420,9 +2420,19 @@ exports.QUERY_REMIND_TASKS = `
|
|||||||
priority
|
priority
|
||||||
job {
|
job {
|
||||||
id
|
id
|
||||||
|
ownr_co_nm
|
||||||
|
ownr_fn
|
||||||
|
ownr_ln
|
||||||
|
v_make_desc
|
||||||
|
v_model_desc
|
||||||
|
v_model_yr
|
||||||
ro_number
|
ro_number
|
||||||
}
|
}
|
||||||
jobid
|
jobid
|
||||||
|
bodyshop {
|
||||||
|
shopname
|
||||||
|
}
|
||||||
|
bodyshopid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
Reference in New Issue
Block a user