upd: api mobile project fitur baru

Deskripsi:
- api mobile get data detail tugas project
- api mobile tambah detail tugas project
- api mobile edit detail tugas project
- api mobile tambah data project > detail tugas

No Issues
This commit is contained in:
2025-08-20 15:18:35 +08:00
parent acfc574616
commit 499c7441ad
3 changed files with 57 additions and 5 deletions

View File

@@ -162,7 +162,7 @@ export async function GET(request: Request, context: { params: { id: string } })
export async function POST(request: Request, context: { params: { id: string } }) {
try {
const { id } = context.params
const { name, dateStart, dateEnd, user } = await request.json()
const { name, dateStart, dateEnd, user, dataDetail } = await request.json()
const userMobile = await funGetUserById({ id: String(user) })
@@ -197,6 +197,21 @@ export async function POST(request: Request, context: { params: { id: string } }
}
})
if (dataDetail.length > 0) {
const dataDetailFix = dataDetail.map((v: any) => ({
...v,
idTask: dataCreate.id,
date: new Date(v.date),
timeStart: v.timeStart == null ? null : new Date(new Date('1970-01-01 ' + v.timeStart).getTime() - (new Date('1970-01-01 ' + v.timeStart).getTimezoneOffset() * 60000)).toISOString(),
timeEnd: v.timeEnd == null ? null : new Date(new Date('1970-01-01 ' + v.timeEnd).getTime() - (new Date('1970-01-01 ' + v.timeEnd).getTimezoneOffset() * 60000)).toISOString(),
}))
const dataDetailCreate = await prisma.projectTaskDetail.createMany({
data: dataDetailFix
})
}
// create log user
const log = await createLogUserMobile({ act: 'CREATE', desc: 'User membuat data tahapan kegiatan', table: 'projectTask', data: String(dataCreate.id), user: userMobile.id })