feat: send alert to user when assignedTo processed permit
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
UpdateProcessedInput,
|
||||
} from "./processed.schema";
|
||||
import { createNote } from "../note/note.service";
|
||||
import { createAlert } from "../alert/alert.service";
|
||||
|
||||
export async function getProcessedPermit(permitId: String, tenantId: String) {
|
||||
return await processedModel
|
||||
@@ -37,7 +38,7 @@ export async function updateProcessed(
|
||||
|
||||
if (updateProcessedResult) {
|
||||
for (const key in input) {
|
||||
if (["manualStatus", "utility"].includes(key)) {
|
||||
if (["manualStatus", "utility", "assignedTo"].includes(key)) {
|
||||
let msg = "";
|
||||
|
||||
if (input[key] === null) {
|
||||
@@ -54,6 +55,17 @@ export async function updateProcessed(
|
||||
"processed",
|
||||
user
|
||||
);
|
||||
|
||||
if (key == "assignedTo" && input[key] != null) {
|
||||
await createAlert(
|
||||
user.tenantId,
|
||||
`You are assigned to ${updateProcessedResult.permitNumber}`,
|
||||
"user",
|
||||
input.assignedTo,
|
||||
updateProcessedResult.pid,
|
||||
"processed"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user