Merge pull request #453 from bipproduction/amalia/27-mei-25
Amalia/27 mei 25
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { funSendWebPush, prisma } from "@/module/_global";
|
import { prisma } from "@/module/_global";
|
||||||
import { funGetUserByCookies, funGetUserById } from "@/module/auth";
|
import { funGetUserById } from "@/module/auth";
|
||||||
import { createLogUser, createLogUserMobile } from "@/module/user";
|
import { createLogUserMobile } from "@/module/user";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
@@ -127,17 +127,18 @@ export async function POST(request: Request) {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
const sent = (await request.json())
|
const sent = (await request.json())
|
||||||
const user = await funGetUserById({ id: String(sent.user) })
|
const user = sent.user
|
||||||
if (user.id == undefined) {
|
const userMobile = await funGetUserById({ id: String(user) })
|
||||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
|
||||||
|
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const userId = user.id
|
const userId = userMobile.id
|
||||||
const userRoleLogin = user.idUserRole
|
const userRoleLogin = userMobile.idUserRole
|
||||||
|
|
||||||
let fixGroup
|
let fixGroup
|
||||||
if (sent.data.idGroup == "null" || sent.data.idGroup == undefined || sent.data.idGroup == "") {
|
if (sent.data.idGroup == "null" || sent.data.idGroup == undefined || sent.data.idGroup == "") {
|
||||||
fixGroup = user.idGroup
|
fixGroup = userMobile.idGroup
|
||||||
} else {
|
} else {
|
||||||
fixGroup = sent.data.idGroup
|
fixGroup = sent.data.idGroup
|
||||||
}
|
}
|
||||||
@@ -147,10 +148,10 @@ export async function POST(request: Request) {
|
|||||||
const data = await prisma.division.create({
|
const data = await prisma.division.create({
|
||||||
data: {
|
data: {
|
||||||
name: sent.data.name,
|
name: sent.data.name,
|
||||||
idVillage: String(user.idVillage),
|
idVillage: String(userMobile.idVillage),
|
||||||
idGroup: fixGroup,
|
idGroup: fixGroup,
|
||||||
desc: sent.data.desc,
|
desc: sent.data.desc,
|
||||||
createdBy: String(user.id)
|
createdBy: String(userMobile.id)
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true
|
id: true
|
||||||
|
|||||||
@@ -141,14 +141,16 @@ export async function POST(request: Request) {
|
|||||||
|
|
||||||
if (task.length > 0) {
|
if (task.length > 0) {
|
||||||
const dataTask = task.map((v: any) => ({
|
const dataTask = task.map((v: any) => ({
|
||||||
..._.omit(v, ["dateStart", "dateEnd", "title"]),
|
..._.omit(v, ["dateStart", "dateEnd", "title", "dateStartFix", "dateEndFix"]),
|
||||||
idDivision: idDivision,
|
idDivision: idDivision,
|
||||||
idProject: data.id,
|
idProject: data.id,
|
||||||
title: v.title,
|
title: v.title,
|
||||||
dateStart: new Date(v.dateStart),
|
dateStart: new Date(v.dateStartFix),
|
||||||
dateEnd: new Date(v.dateEnd),
|
dateEnd: new Date(v.dateEndFix),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
console.log(dataTask)
|
||||||
|
|
||||||
const insertTask = await prisma.divisionProjectTask.createMany({
|
const insertTask = await prisma.divisionProjectTask.createMany({
|
||||||
data: dataTask
|
data: dataTask
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user