upd: project dan task
Deskripsi: - tambah project - perbaiki task No Issues
This commit is contained in:
@@ -12,6 +12,8 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
||||
}
|
||||
const { id } = context.params;
|
||||
const { idProject } = (await request.json());
|
||||
|
||||
const data = await prisma.projectTask.count({
|
||||
where: {
|
||||
id: id,
|
||||
@@ -37,6 +39,35 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
||||
},
|
||||
});
|
||||
|
||||
const dataTask = await prisma.projectTask.findMany({
|
||||
where: {
|
||||
isActive: true,
|
||||
idProject: idProject,
|
||||
}
|
||||
})
|
||||
|
||||
const semua = dataTask.length
|
||||
const selesai = dataTask.filter((item) => item.status == 1).length
|
||||
const prosess = Math.ceil((selesai / semua) * 100)
|
||||
let statusProject = 1
|
||||
|
||||
if (prosess == 100) {
|
||||
statusProject = 2
|
||||
} else if (prosess == 0) {
|
||||
statusProject = 0
|
||||
}
|
||||
|
||||
|
||||
const updProject = await prisma.project.update({
|
||||
where: {
|
||||
id: idProject
|
||||
},
|
||||
data: {
|
||||
status: statusProject
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
@@ -87,6 +118,8 @@ export async function PUT(request: Request, context: { params: { id: string } })
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// const cek progress
|
||||
const dataTask = await prisma.projectTask.findMany({
|
||||
where: {
|
||||
isActive: true,
|
||||
|
||||
@@ -13,6 +13,7 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
||||
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
|
||||
}
|
||||
const { id } = context.params;
|
||||
const { idProject } = (await request.json());
|
||||
const data = await prisma.divisionProjectTask.count({
|
||||
where: {
|
||||
id: id,
|
||||
@@ -38,6 +39,34 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
||||
},
|
||||
});
|
||||
|
||||
// const cek progress
|
||||
const dataTask = await prisma.divisionProjectTask.findMany({
|
||||
where: {
|
||||
isActive: true,
|
||||
idProject: idProject
|
||||
}
|
||||
})
|
||||
|
||||
const semua = dataTask.length
|
||||
const selesai = _.filter(dataTask, { status: 1 }).length
|
||||
const progress = Math.ceil((selesai / semua) * 100)
|
||||
let statusProject = 1
|
||||
|
||||
if (progress == 100) {
|
||||
statusProject = 2
|
||||
} else if (progress == 0) {
|
||||
statusProject = 0
|
||||
}
|
||||
|
||||
const updProject = await prisma.divisionProject.update({
|
||||
where: {
|
||||
id: idProject
|
||||
},
|
||||
data: {
|
||||
status: statusProject
|
||||
}
|
||||
})
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
|
||||
Reference in New Issue
Block a user