feat: accept task notification
This commit is contained in:
parent
f583448e5f
commit
b518488112
1 changed files with 29 additions and 12 deletions
|
|
@ -997,20 +997,37 @@ export class UserTaskController extends Controller {
|
|||
|
||||
await prisma.$transaction(async (tx) => {
|
||||
const promises = body.taskOrderId.flatMap((taskOrderId) => [
|
||||
tx.taskOrder.update({
|
||||
where: { id: taskOrderId },
|
||||
data: {
|
||||
taskOrderStatus: TaskOrderStatus.InProgress,
|
||||
userTask: {
|
||||
deleteMany: { userId: req.user.sub },
|
||||
create: {
|
||||
userId: req.user.sub,
|
||||
userTaskStatus: UserTaskStatus.Accept,
|
||||
acceptedAt: new Date(),
|
||||
tx.taskOrder
|
||||
.update({
|
||||
where: { id: taskOrderId },
|
||||
data: {
|
||||
taskOrderStatus: TaskOrderStatus.InProgress,
|
||||
userTask: {
|
||||
deleteMany: { userId: req.user.sub },
|
||||
create: {
|
||||
userId: req.user.sub,
|
||||
userTaskStatus: UserTaskStatus.Accept,
|
||||
acceptedAt: new Date(),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
})
|
||||
.then(async (v) => {
|
||||
await tx.notification.createMany({
|
||||
data: [
|
||||
{
|
||||
title: "สถานะใบส่งงานมีการเปลี่ยนแปลง / Order Status Changed",
|
||||
detail: "รหัสใบสั่งงาน / Order : " + v.code + " InProgress",
|
||||
receiverId: v.createdByUserId,
|
||||
},
|
||||
{
|
||||
title: "มีการรับงาน / Task Accepted",
|
||||
detail: "รหัสใบสั่งงาน / Order : " + v.code,
|
||||
receiverId: v.createdByUserId,
|
||||
},
|
||||
],
|
||||
});
|
||||
}),
|
||||
tx.task.updateMany({
|
||||
where: {
|
||||
taskOrderId: taskOrderId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue