feat: send alert to user when assignedTo processed permit
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
|||||||
UpdateProcessedInput,
|
UpdateProcessedInput,
|
||||||
} from "./processed.schema";
|
} from "./processed.schema";
|
||||||
import { createNote } from "../note/note.service";
|
import { createNote } from "../note/note.service";
|
||||||
|
import { createAlert } from "../alert/alert.service";
|
||||||
|
|
||||||
export async function getProcessedPermit(permitId: String, tenantId: String) {
|
export async function getProcessedPermit(permitId: String, tenantId: String) {
|
||||||
return await processedModel
|
return await processedModel
|
||||||
@@ -37,7 +38,7 @@ export async function updateProcessed(
|
|||||||
|
|
||||||
if (updateProcessedResult) {
|
if (updateProcessedResult) {
|
||||||
for (const key in input) {
|
for (const key in input) {
|
||||||
if (["manualStatus", "utility"].includes(key)) {
|
if (["manualStatus", "utility", "assignedTo"].includes(key)) {
|
||||||
let msg = "";
|
let msg = "";
|
||||||
|
|
||||||
if (input[key] === null) {
|
if (input[key] === null) {
|
||||||
@@ -54,6 +55,17 @@ export async function updateProcessed(
|
|||||||
"processed",
|
"processed",
|
||||||
user
|
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