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