upd: update status project
Deskripsi; - update status project saat menambahkan detail task project ketika project sudah berstatus selesai menjadi sedang dikerjakan No Issues
This commit is contained in:
@@ -212,6 +212,36 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// const cek progress
|
||||||
|
const dataTask = await prisma.projectTask.findMany({
|
||||||
|
where: {
|
||||||
|
isActive: true,
|
||||||
|
idProject: id,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
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 update = await prisma.project.update({
|
||||||
|
where: {
|
||||||
|
id: id
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
status: statusProject
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
// create log user
|
// create log user
|
||||||
const log = await createLogUserMobile({ act: 'CREATE', desc: 'User membuat data tahapan kegiatan', table: 'projectTask', data: String(dataCreate.id), user: userMobile.id })
|
const log = await createLogUserMobile({ act: 'CREATE', desc: 'User membuat data tahapan kegiatan', table: 'projectTask', data: String(dataCreate.id), user: userMobile.id })
|
||||||
|
|
||||||
|
|||||||
@@ -206,6 +206,36 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// const cek progress
|
||||||
|
const dataTask = await prisma.projectTask.findMany({
|
||||||
|
where: {
|
||||||
|
isActive: true,
|
||||||
|
idProject: id,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
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 update = await prisma.project.update({
|
||||||
|
where: {
|
||||||
|
id: id
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
status: statusProject
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
// create log user
|
// create log user
|
||||||
const log = await createLogUser({ act: 'CREATE', desc: 'User membuat data tahapan kegiatan', table: 'projectTask', data: String(dataCreate.id) })
|
const log = await createLogUser({ act: 'CREATE', desc: 'User membuat data tahapan kegiatan', table: 'projectTask', data: String(dataCreate.id) })
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user