# Forum Report

## feat
- Repot posting
- Report komentar
### No issuee
This commit is contained in:
2024-03-18 14:02:01 +08:00
parent a77d728a5f
commit de0790aade
33 changed files with 605 additions and 49 deletions

View File

@@ -0,0 +1,29 @@
"use server";
import prisma from "@/app/lib/prisma";
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
export async function forum_funCreateReportKomentar(
komentarId: string,
value: string
) {
const authorId = await User_getUserId();
const cekId = await prisma.forumMaster_KategoriReport.findFirst({
where: {
title: value,
},
});
const createReport = await prisma.forum_ReportKomentar.create({
data: {
userId: authorId,
forumMaster_KategoriReportId: cekId?.id,
forum_KomentarId: komentarId,
},
});
if (!createReport)
return { status: 400, message: "Gagal menambahkan report komentar !" };
return { status: 201, message: "Berhasil me-report komentar !" };
}

View File

@@ -0,0 +1,21 @@
"use server";
import prisma from "@/app/lib/prisma";
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
export async function forum_funCreateReportKomentarLainnya(
komentarId: string,
deskripsi: string
) {
const authorId = await User_getUserId();
const create = await prisma.forum_ReportKomentar.create({
data: {
forum_KomentarId: komentarId,
deskripsi: deskripsi,
userId: authorId,
},
});
if (!create) return { status: 400, message: "Gagal menambah report !" };
return { status: 201, message: "Berhasil menambah report !" };
}

View File

@@ -0,0 +1,29 @@
"use server";
import prisma from "@/app/lib/prisma";
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
import { revalidatePath } from "next/cache";
export async function forum_funCreateReportPosting(
postingId: string,
value: string,
) {
const authorId = await User_getUserId();
const cekId = await prisma.forumMaster_KategoriReport.findFirst({
where: {
title: value,
},
});
const createReport = await prisma.forum_ReportPosting.create({
data: {
userId: authorId,
forum_PostingId: postingId,
forumMaster_KategoriReportId: cekId?.id,
},
});
if (!createReport)
return { status: 400, message: "Gagal menambahkan report posting!" };
return { status: 201, message: "Berhasil me-report posting!" };
}

View File

@@ -0,0 +1,21 @@
"use server";
import prisma from "@/app/lib/prisma";
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
export async function forum_funCreateReportPostingLainnya(
postingId: string,
deskripsi: string
) {
const authorId = await User_getUserId();
const create = await prisma.forum_ReportPosting.create({
data: {
forum_PostingId: postingId,
deskripsi: deskripsi,
userId: authorId,
},
});
if (!create) return { status: 400, message: "Gagal menambah report !" };
return { status: 201, message: "Berhasil menambah report !" };
}

View File

@@ -0,0 +1,11 @@
"use server";
import prisma from "@/app/lib/prisma";
export async function forum_getMasterKategoriReport() {
const data = await prisma.forumMaster_KategoriReport.findMany({});
const changeType = JSON.stringify(data, null,2)
return data;
}