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:
@@ -2,10 +2,9 @@ import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import _ from "lodash";
|
||||
|
||||
export async function GET(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
export { GET, PUT };
|
||||
|
||||
async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const search = searchParams.get("search");
|
||||
const page = searchParams.get("page");
|
||||
@@ -14,13 +13,13 @@ export async function GET(
|
||||
|
||||
const { id } = params;
|
||||
try {
|
||||
|
||||
const data = await prisma.forum_Posting.findFirst({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
isActive: true,
|
||||
diskusi: true,
|
||||
ForumMaster_StatusPosting: {
|
||||
select: {
|
||||
@@ -76,3 +75,46 @@ export async function GET(
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function PUT(request: Request, { params }: { params: { id: string } }) {
|
||||
const { id } = params;
|
||||
try {
|
||||
const data = await prisma.forum_Posting.update({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
data: {
|
||||
isActive: false,
|
||||
},
|
||||
});
|
||||
|
||||
const deactivateComment = await prisma.forum_Komentar.updateMany({
|
||||
where: {
|
||||
forum_PostingId: id,
|
||||
},
|
||||
data: {
|
||||
isActive: false,
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[DEACTIVATE COMMENT]", deactivateComment);
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: true,
|
||||
message: "Success deactivate posting",
|
||||
data: data,
|
||||
},
|
||||
{ status: 200 }
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("[ERROR DEACTIVATE POSTING]", error);
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
message: "Error deactivate posting",
|
||||
reason: (error as Error).message,
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user