Mobile API: Admin Forum

Add:
src/app/api/mobile/admin/forum/[id]/report-comment/
src/app/api/mobile/admin/forum/[id]/report-posting/

Fix:
src/app/api/mobile/admin/forum/[id]/comment/route.ts
src/app/api/mobile/admin/forum/[id]/route.ts
src/app/api/mobile/admin/forum/route.ts

### No Issue
This commit is contained in:
nabillah
2025-10-20 16:28:00 +08:00
parent 02d685f1aa
commit d2ec9496e8
5 changed files with 323 additions and 12 deletions

View File

@@ -7,7 +7,9 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
const { searchParams } = new URL(request.url);
const category = searchParams.get("category");
const search = searchParams.get("search");
const page = searchParams.get("page");
const takeData = 10;
const skipData = Number(page) * takeData - takeData;
let fixData;
try {
@@ -50,6 +52,8 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
};
} else if (category === "posting") {
fixData = await prisma.forum_Posting.findMany({
take: page ? takeData : undefined,
skip: page ? skipData : undefined,
orderBy: {
createdAt: "desc",
},
@@ -74,7 +78,88 @@ async function GET(request: Request, { params }: { params: { name: string } }) {
},
});
} else if (category === "report_posting") {
fixData = await prisma.forum_ReportPosting.findMany({
take: page ? takeData : undefined,
skip: page ? skipData : undefined,
orderBy: {
createdAt: "desc",
},
where: {
Forum_Posting: {
isActive: true,
diskusi: {
contains: search ? search : "",
mode: "insensitive",
},
},
},
select: {
id: true,
deskripsi: true,
createdAt: true,
User: {
select: {
id: true,
username: true,
Profile: {
select: {
name: true,
},
},
},
},
ForumMaster_KategoriReport: {
select: {
id: true,
title: true,
deskripsi: true,
},
},
Forum_Posting: {
select: {
id: true,
diskusi: true,
},
},
},
});
} else if (category === "report_comment") {
fixData = await prisma.forum_ReportKomentar.findMany({
take: page ? takeData : undefined,
skip: page ? skipData : undefined,
orderBy: {
createdAt: "desc",
},
where: {
Forum_Komentar: {
isActive: true,
komentar: {
contains: search ? search : "",
mode: "insensitive",
},
},
},
include: {
ForumMaster_KategoriReport: true,
User: {
select: {
username: true,
Profile: {
select: {
id: true,
name: true,
},
},
},
},
Forum_Komentar: {
select: {
id: true,
komentar: true,
},
},
},
});
} else {
return NextResponse.json(
{