upd: task
Deskripsi : - realtime pada halaman list task No Issues
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
import { DIR, funUploadFile, prisma } from "@/module/_global";
|
||||
import { funGetUserByCookies } from "@/module/auth";
|
||||
import _, { ceil } from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import moment from "moment";
|
||||
import { createLogUser } from "@/module/user";
|
||||
import _, { ceil } from "lodash";
|
||||
import moment from "moment";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
|
||||
// GET ALL DATA TUGAS DIVISI
|
||||
@@ -113,6 +111,8 @@ export async function POST(request: Request) {
|
||||
const body = await request.formData()
|
||||
const dataBody = body.get("data")
|
||||
const cekFile = body.has("file0")
|
||||
const userId = user.id
|
||||
const userRoleLogin = user.idUserRole
|
||||
|
||||
const { title, task, member, idDivision } = JSON.parse(dataBody as string)
|
||||
|
||||
@@ -233,6 +233,25 @@ export async function POST(request: Request) {
|
||||
desc: 'Terdapat tugas baru. Silahkan periksa detailnya.'
|
||||
}))
|
||||
|
||||
if (userRoleLogin != "supadmin") {
|
||||
const perbekel = await prisma.user.findFirst({
|
||||
where: {
|
||||
isActive: true,
|
||||
idUserRole: "supadmin",
|
||||
idVillage: user.idVillage
|
||||
}
|
||||
})
|
||||
|
||||
dataNotif.push({
|
||||
idUserTo: perbekel?.id,
|
||||
idUserFrom: userId,
|
||||
category: 'division/' + idDivision + '/task',
|
||||
idContent: data.id,
|
||||
title: 'Tugas Baru',
|
||||
desc: 'Terdapat tugas baru. Silahkan periksa detailnya.'
|
||||
})
|
||||
}
|
||||
|
||||
const insertNotif = await prisma.notifications.createMany({
|
||||
data: dataNotif
|
||||
})
|
||||
@@ -242,7 +261,7 @@ export async function POST(request: Request) {
|
||||
const log = await createLogUser({ act: 'CREATE', desc: 'User membuat tugas divisi baru', table: 'divisionProject', data: data.id })
|
||||
|
||||
|
||||
return NextResponse.json({ success: true, message: "Berhasil membuat tugas divisi" }, { status: 200 });
|
||||
return NextResponse.json({ success: true, message: "Berhasil membuat tugas divisi", notif:dataNotif }, { status: 200 });
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
Reference in New Issue
Block a user