Fix API notification to report comment

Fix:
- src/app/api/mobile/admin/forum/[id]/comment/route.ts
- src/app/api/mobile/admin/forum/[id]/route.ts
- src/app/api/mobile/forum/[id]/preview-report-posting/route.ts
- src/app/api/mobile/forum/[id]/report-commentar/route.ts
- src/app/api/mobile/forum/[id]/report-posting/route.ts
- src/lib/mobile/route-page-mobile.ts
- tsconfig.json

Deleted:
- src/app/api/mobile/forum/[id]/report-comment/route.ts

Add:
- src/app/api/mobile/forum/[id]/preview-report-comment/
- src/app/api/mobile/forum/[id]/report-comment-del-soon/

### No Issue
This commit is contained in:
2026-01-19 17:38:15 +08:00
parent cb0845e264
commit 3c6dde6204
9 changed files with 147 additions and 84 deletions

View File

@@ -1,6 +1,12 @@
import _ from "lodash";
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
import { sendNotificationMobileToOneUser } from "@/lib/mobile/notification/send-notification";
import {
NotificationMobileBodyType,
NotificationMobileTitleType,
} from "../../../../../../../../types/type-mobile-notification";
import { routeUserMobile } from "@/lib/mobile/route-page-mobile";
export { GET, PUT };
@@ -82,21 +88,43 @@ async function GET(request: Request, { params }: { params: { id: string } }) {
async function PUT(request: Request, { params }: { params: { id: string } }) {
const { id } = params;
const data = await request.json();
console.log("SENDER Comment", data);
try {
const deleteData = await prisma.forum_Komentar.update({
const deactiveComment = await prisma.forum_Komentar.update({
where: {
id: id,
},
data: {
isActive: false,
},
select: {
authorId: true,
komentar: true,
},
});
// SEND NOTIFICATION
await sendNotificationMobileToOneUser({
recipientId: deactiveComment?.authorId as string,
senderId: data?.senderId,
payload: {
title: "Penghapusan Komentar" as NotificationMobileTitleType,
body: `Komentar anda telah dilaporkan: ${deactiveComment?.komentar}` as NotificationMobileBodyType,
type: "announcement",
kategoriApp: "FORUM",
deepLink: routeUserMobile.forumPreviewReportComment({ id: id }),
},
});
console.log("[DEACTIVATE COMMENT]");
return NextResponse.json(
{
success: true,
message: "Success deactivate comment",
data: deleteData,
// data: deactiveComment,
},
{ status: 200 }
);

View File

@@ -87,10 +87,10 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
const data = await request.json();
const { senderId } = data;
console.log("SENDER", senderId);
console.log("SENDER POSTING", data);
try {
const data = await prisma.forum_Posting.update({
const deactivePosting = await prisma.forum_Posting.update({
where: {
id: id,
},
@@ -114,23 +114,23 @@ async function PUT(request: Request, { params }: { params: { id: string } }) {
// SEND NOTIFICATION
await sendNotificationMobileToOneUser({
recipientId: data?.authorId as string,
recipientId: deactivePosting?.authorId as string,
senderId: senderId,
payload: {
title: "Penghapusan Postingan" as NotificationMobileTitleType,
body: `Postingan anda telah dilaporkan: ${data?.diskusi}` as NotificationMobileBodyType,
body: `Postingan anda telah dilaporkan: ${deactivePosting?.diskusi}` as NotificationMobileBodyType,
type: "announcement",
kategoriApp: "FORUM",
deepLink: routeUserMobile.forumPreviewReportPosting({ id: id }),
},
});
console.log("[DEACTIVATE COMMENT]", deactivateComment);
console.log("[DEACTIVATE POSTINGAN & COMMENT]", deactivateComment);
return NextResponse.json(
{
success: true,
message: "Success deactivate posting",
data: data,
data: deactivePosting,
},
{ status: 200 }
);