upd: api mobile

Deskripsi:
- test api mobile upload gambar banner
- elysia

No Issues
This commit is contained in:
amel
2025-05-16 10:10:55 +08:00
parent 30b4476e0b
commit 85d13f766a
6 changed files with 85 additions and 9 deletions

View File

@@ -1,15 +1,17 @@
import { prisma } from "@/module/_global";
import { funGetUserByCookies } from "@/module/auth";
import { createLogUser } from "@/module/user";
import { funGetUserById } from "@/module/auth";
import { createLogUserMobile } from "@/module/user";
import { NextResponse } from "next/server";
// HAPUS PROJECT YG TELAH DIBATALKAN
export async function DELETE(request: Request, context: { params: { id: string } }) {
try {
const user = await funGetUserByCookies()
if (user.id == undefined) {
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 401 });
const { user } = await request.json()
const userMobile = await funGetUserById({ id: String(user) })
if (userMobile.id == "null" || userMobile.id == undefined || userMobile.id == "") {
return NextResponse.json({ success: false, message: "Anda harus login untuk mengakses ini" }, { status: 200 });
}
const { id } = context.params
@@ -24,7 +26,7 @@ export async function DELETE(request: Request, context: { params: { id: string }
{
success: false, message: "Gagal mendapatkan kegiatan, data tidak ditemukan",
},
{ status: 404 }
{ status: 200 }
);
}
@@ -38,8 +40,8 @@ export async function DELETE(request: Request, context: { params: { id: string }
})
// create log user
const log = await createLogUser({ act: 'DELETE', desc: 'User menghapus data kegiatan', table: 'project', data: String(id) })
return NextResponse.json({ success: true, message: "Kegiatan berhasil dihapus", user: user.id }, { status: 200 });
const log = await createLogUserMobile({ act: 'DELETE', desc: 'User menghapus data kegiatan', table: 'project', data: String(id), user: userMobile.id })
return NextResponse.json({ success: true, message: "Kegiatan berhasil dihapus" }, { status: 200 });
} catch (error) {
console.error(error);