Resolve missing query paramters.

This commit is contained in:
Patrick Fic
2024-04-19 12:41:26 -07:00
parent 683293d042
commit 6b157ed43c
2 changed files with 24 additions and 11 deletions

View File

@@ -166,15 +166,13 @@ const taskAssignedEmail = async (req, res) => {
const dirty = req.body.event.data?.old && req.body.event.data?.old?.assigned_to; const dirty = req.body.event.data?.old && req.body.event.data?.old?.assigned_to;
//Query to get the employee assigned currently. //Query to get the employee assigned currently.
const { const { tasks_by_pk } = await client.request(queries.QUERY_TASK_BY_ID, {
employees_by_pk: { user_email } id: newTask.id
} = await client.request(queries.QUERY_EMPLOYEE_EMAIL_BY_ID, {
id: newTask.assigned_to
}); });
sendMail( sendMail(
"assigned", "assigned",
user_email, tasks_by_pk.assigned_to_employee.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( generateTemplateArgs(
@@ -182,8 +180,8 @@ const taskAssignedEmail = async (req, res) => {
newTask.priority, newTask.priority,
newTask.description, newTask.description,
newTask.due_date, newTask.due_date,
newTask.bodyshop, tasks_by_pk.bodyshop,
newTask.job, tasks_by_pk.job,
newTask.id newTask.id
) )
) )

View File

@@ -2443,11 +2443,26 @@ exports.UPDATE_TASKS_REMIND_AT_SENT = `mutation UPDATE_TASK_REMIND_AT_SENT($task
} }
}`; }`;
exports.QUERY_EMPLOYEE_EMAIL_BY_ID = ` exports.QUERY_TASK_BY_ID = `
query QUERY_EMPLOYEE_EMAIL_BY_ID($id: uuid!) { query QUERY_TASK_BY_ID($id: uuid!) {
employees_by_pk(id: $id) { tasks_by_pk(id: $id) {
id id
user_email assigned_to_employee{
id
user_email
}
bodyshop{
shopname
}
job{
ro_number
ownr_fn
ownr_ln
ownr_co_nm
v_make_desc
v_model_desc
v_model_yr
}
} }
} }