upd: api mobile

Deskripsi:
- api project upload tambah file
- api project delete file
- api project tambah data upload file

- api project check file

NO Issues
This commit is contained in:
amel
2025-05-20 14:39:46 +08:00
parent 2de14e7e0e
commit 0f6677f142
2 changed files with 27 additions and 28 deletions

View File

@@ -1,5 +1,4 @@
import { title } from 'process';
import { DIR, funSendWebPush, funUploadFile, prisma } from "@/module/_global";
import { DIR, funUploadFile, prisma } from "@/module/_global";
import { funGetUserById } from "@/module/auth";
import { createLogUserMobile } from "@/module/user";
import _, { ceil } from "lodash";
@@ -150,7 +149,6 @@ export async function GET(request: Request) {
// CREATE PROJECT
export async function POST(request: Request) {
try {
const body = await request.formData()
const dataBody = body.get("data")
const cekFile = body.has("file0")
@@ -206,6 +204,7 @@ export async function POST(request: Request) {
}
if (cekFile) {
body.delete("data")
for (var pair of body.entries()) {
if (String(pair[0]).substring(0, 4) == "file") {
const file = body.get(pair[0]) as File
@@ -347,7 +346,7 @@ export async function POST(request: Request) {
// create log user
const log = await createLogUserMobile({ act: 'CREATE', desc: 'User membuat data kegiatan', table: 'project', data: data.id, user: userMobile.id })
return NextResponse.json({ success: true, message: "Berhasil membuat kegiatan"}, { status: 200 });
return NextResponse.json({ success: true, message: "Berhasil membuat kegiatan" }, { status: 200 });
} catch (error) {
console.error(error);