fix: tugas dan home divisi
deskripsi: - klo tugas sudah batal ga usah di tampilin - order by tahapan tugas - push router ketika selesai edit tahapan tugas No Issues
This commit is contained in:
@@ -86,7 +86,12 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
idDivision: String(id),
|
idDivision: String(id),
|
||||||
status: 0,
|
status: 0,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
dateStart: new Date()
|
dateStart: new Date(),
|
||||||
|
DivisionProject: {
|
||||||
|
status: {
|
||||||
|
lt: 3
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ export async function GET(request: Request, context: { params: { id: string } })
|
|||||||
dateEnd: true,
|
dateEnd: true,
|
||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
status: 'desc'
|
createdAt: 'asc'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -201,6 +201,34 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// const cek progress
|
||||||
|
const dataTask = await prisma.divisionProjectTask.findMany({
|
||||||
|
where: {
|
||||||
|
isActive: true,
|
||||||
|
idProject: id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
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: id
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
status: statusProject
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// create log user
|
// create log user
|
||||||
const log = await createLogUser({ act: 'CREATE', desc: 'User menambahkan detail tugas divisi', table: 'divisionProjectTask', data: create.id })
|
const log = await createLogUser({ act: 'CREATE', desc: 'User menambahkan detail tugas divisi', table: 'divisionProjectTask', data: create.id })
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ export default function EditDetailTask() {
|
|||||||
const param = useParams<{ id: string, detail: string }>()
|
const param = useParams<{ id: string, detail: string }>()
|
||||||
const [openModal, setOpenModal] = useState(false)
|
const [openModal, setOpenModal] = useState(false)
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
|
const [idTugas, setIdTugas] = useState("")
|
||||||
const tema = useHookstate(TEMA)
|
const tema = useHookstate(TEMA)
|
||||||
|
|
||||||
async function onSubmit() {
|
async function onSubmit() {
|
||||||
@@ -50,6 +51,7 @@ export default function EditDetailTask() {
|
|||||||
|
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
toast.success(res.message);
|
toast.success(res.message);
|
||||||
|
router.push(`/division/${param.id}/task/${idTugas}`)
|
||||||
} else {
|
} else {
|
||||||
toast.error(res.message);
|
toast.error(res.message);
|
||||||
}
|
}
|
||||||
@@ -65,6 +67,7 @@ export default function EditDetailTask() {
|
|||||||
setLoading(true)
|
setLoading(true)
|
||||||
const res = await funGetDetailTask(param.detail);
|
const res = await funGetDetailTask(param.detail);
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
|
setIdTugas(res.data.idProject)
|
||||||
setTitle(res.data.title)
|
setTitle(res.data.title)
|
||||||
setValue([
|
setValue([
|
||||||
new Date(moment(res.data.dateStart).format('YYYY-MM-DD')),
|
new Date(moment(res.data.dateStart).format('YYYY-MM-DD')),
|
||||||
|
|||||||
Reference in New Issue
Block a user