upd: project dan task

Deskripsi:
- tambah project
- perbaiki task

No Issues
This commit is contained in:
amel
2024-08-23 18:10:11 +08:00
parent df2f61e833
commit 5b05edaf38
14 changed files with 163 additions and 115 deletions

View File

@@ -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,