Mobile API

Forum add:
- mobile/forum/[id]/comment
- mobile/forum/[id]/report-comment
- mobile/forum/[id]/report-commentar
- mobile/forum/[id]/report-postin
- mobile/master/forum-report

Fix:
- mobile/forum/[id]/route
- mobile/forum/route

### No isssue
This commit is contained in:
2025-09-27 00:01:36 +08:00
parent fab4e2526d
commit a9b57be0a6
8 changed files with 640 additions and 48 deletions

View File

@@ -0,0 +1,54 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export { POST };
async function POST(request: Request, { params }: { params: { id: string } }) {
let fixData;
const { id } = params;
const { data } = await request.json();
console.log("[DATA]", data);
console.log("[ID]", id);
try {
if (data.categoryId) {
fixData = await prisma.forum_ReportPosting.create({
data: {
forum_PostingId: id,
userId: data.authorId,
forumMaster_KategoriReportId: data.categoryId,
},
});
} else {
fixData = await prisma.forum_ReportPosting.create({
data: {
forum_PostingId: id,
userId: data.authorId,
deskripsi: data.description,
},
});
}
if (!fixData) {
return NextResponse.json({
status: 400,
success: false,
message: "Gagal membuat report posting",
});
}
return NextResponse.json({
status: 201,
success: true,
message: "Berhasil membuat report posting",
});
} catch (error) {
console.log("[ERROR]", error);
return NextResponse.json({
status: 500,
success: false,
message: "Gagal membuat report posting",
reason: (error as Error).message,
});
}
}