- Tampilan admin untuk komentar
- Hapus komentar
- Hapus postingan
- Lihat report
- Search topik forum
## feat
### No issue
This commit is contained in:
2024-03-25 17:44:27 +08:00
parent de0790aade
commit 8af6c6265f
55 changed files with 2213 additions and 218 deletions

View File

@@ -11,6 +11,7 @@ export async function forum_funCreate(value: string) {
data: {
diskusi: value,
authorId: AuthorId,
forumMaster_StatusPostingId: 1
},
});

View File

@@ -0,0 +1,24 @@
"use server";
import prisma from "@/app/lib/prisma";
import { revalidatePath } from "next/cache";
export async function forum_funEditStatusPostingById(
postingId: string,
statusId: number
) {
const updt = await prisma.forum_Posting.update({
where: {
id: postingId,
},
data: {
forumMaster_StatusPostingId: statusId,
},
});
if (!updt) return { status: 400, message: "Gagal update posting" };
revalidatePath("/dev/forum/main");
revalidatePath("/dev/forum/detail");
revalidatePath("/dev/forum/forumku");
return { status: 200, message: "Berhasil update posting" };
}

View File

@@ -7,11 +7,17 @@ import { forum_countTotalKomenById } from "../count/count_total_komentar_by_id";
export async function forum_getListAllPosting() {
const get = await prisma.forum_Posting.findMany({
orderBy: {
createdAt: "desc",
},
orderBy: [
// {
// forumMaster_StatusPostingId: "asc",
// },
{
createdAt: "desc",
},
],
where: {
isActive: true,
// forumMaster_StatusPostingId: 1
},
select: {
id: true,
@@ -30,6 +36,7 @@ export async function forum_getListAllPosting() {
isActive: true,
},
},
ForumMaster_StatusPosting: true,
// _count: {
// select: {
// Forum_Komentar: true,
@@ -38,17 +45,10 @@ export async function forum_getListAllPosting() {
},
});
// const data = get.map((v) => ({
// ..._.omit(v, ['Forum_Komentar']),
// total_coment: v.Forum_Komentar.filter((v) => v.isActive).length,
// }));
const data = get.map((val) => ({
..._.omit(val, ["Forum_Komentar"]),
_count: val.Forum_Komentar.length,
}));
// console.log(JSON.stringify(data, null, 2));
return data;
}

View File

@@ -30,6 +30,7 @@ export async function forum_getListPostingByAuhtorId(authorId: string) {
isActive: true,
},
},
ForumMaster_StatusPosting: true
},
});

View File

@@ -25,6 +25,8 @@ export async function forum_getOnePostingById(postingId: string) {
Forum_Komentar: true,
},
},
ForumMaster_StatusPosting: true
},
});

View File

@@ -0,0 +1,50 @@
"use server"
import prisma from "@/app/lib/prisma";
import _ from "lodash"
export async function forum_funSearchListPosting(text:string) {
const get = await prisma.forum_Posting.findMany({
orderBy: [
// {
// forumMaster_StatusPostingId: "asc",
// },
{
createdAt: "desc",
},
],
take: 10,
where: {
diskusi: {
contains: text,
mode: "insensitive",
},
},
select: {
id: true,
diskusi: true,
createdAt: true,
isActive: true,
authorId: true,
Author: {
select: {
id: true,
Profile: true,
},
},
Forum_Komentar: {
where: {
isActive: true,
},
},
ForumMaster_StatusPosting: true,
},
});
const data = get.map((val) => ({
..._.omit(val, ["Forum_Komentar"]),
_count: val.Forum_Komentar.length,
}));
return data;
}