Merge pull request #441 from bipproduction/amalia/06-mei-25
upd: api mobile
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { prisma } from "@/module/_global";
|
||||
import { funGetUserByCookies } from "@/module/auth";
|
||||
import { createLogUser } from "@/module/user";
|
||||
import { funGetUserByCookies, funGetUserById } from "@/module/auth";
|
||||
import { createLogUser, createLogUserMobile } from "@/module/user";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
@@ -53,13 +53,14 @@ export async function POST(request: Request, context: { params: { id: string } }
|
||||
// MENGELUARKAN ANGGOTA
|
||||
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 { id } = context.params
|
||||
const { idUser } = (await request.json());
|
||||
const { idUser, 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 cek = await prisma.discussion.count({
|
||||
@@ -70,7 +71,7 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
||||
})
|
||||
|
||||
if (cek == 0) {
|
||||
return NextResponse.json({ success: false, message: "Gagal, data tidak ditemukan" }, { status: 404 });
|
||||
return NextResponse.json({ success: false, message: "Gagal, data tidak ditemukan" }, { status: 200 });
|
||||
}
|
||||
|
||||
const deleteMember = await prisma.discussionMember.deleteMany({
|
||||
@@ -81,7 +82,7 @@ export async function DELETE(request: Request, context: { params: { id: string }
|
||||
})
|
||||
|
||||
// create log user
|
||||
const log = await createLogUser({ act: 'DELETE', desc: 'User mengeluarkan anggota diskusi umum', table: 'discussion', data: String(id) })
|
||||
const log = await createLogUserMobile({ act: 'DELETE', desc: 'User mengeluarkan anggota diskusi umum', table: 'discussion', data: String(id), user: userMobile.id })
|
||||
|
||||
return NextResponse.json({ success: true, message: "Berhasil mengeluarkan anggota diskusi umum" }, { status: 200 });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user