Perbaikan UI pada Forum
# style: - Tampilan keseluruhan forum di ganti menguikuti UI ## No Issue
This commit is contained in:
@@ -3,27 +3,35 @@
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
|
||||
export async function forum_funCreateReportKomentar(
|
||||
komentarId: string,
|
||||
value: string
|
||||
) {
|
||||
export async function forum_funCreateReportKomentar({
|
||||
komentarId,
|
||||
kategoriId,
|
||||
}: {
|
||||
komentarId: string;
|
||||
kategoriId: any;
|
||||
}) {
|
||||
const authorId = await user_getOneUserId();
|
||||
|
||||
const cekId = await prisma.forumMaster_KategoriReport.findFirst({
|
||||
where: {
|
||||
title: value,
|
||||
title: kategoriId,
|
||||
},
|
||||
});
|
||||
|
||||
const createReport = await prisma.forum_ReportKomentar.create({
|
||||
data: {
|
||||
userId: authorId,
|
||||
forumMaster_KategoriReportId: cekId?.id,
|
||||
forum_KomentarId: komentarId,
|
||||
},
|
||||
});
|
||||
try {
|
||||
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 !" };
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
if (!createReport)
|
||||
return { status: 400, message: "Gagal menambahkan report komentar !" };
|
||||
return { status: 201, message: "Berhasil me-report komentar !" };
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
||||
|
||||
export default async function forum_funCreateNotifikasiToAdmin({
|
||||
data,
|
||||
}: {
|
||||
data: MODEL_NOTIFIKASI;
|
||||
}) {
|
||||
console.log(data);
|
||||
|
||||
// const getAdmin = await prisma.user.findMany({
|
||||
// where: {
|
||||
// active: true,
|
||||
// masterUserRoleId: "2",
|
||||
// },
|
||||
// });
|
||||
|
||||
return { status: 201 };
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export async function forum_getKomentarById(postingId: string) {
|
||||
export async function forum_funGetAllKomentarById(postingId: string) {
|
||||
const data = await prisma.forum_Komentar.findMany({
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
@@ -4,8 +4,19 @@ import prisma from "@/app/lib/prisma";
|
||||
import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token";
|
||||
import _ from "lodash";
|
||||
|
||||
export async function forum_getListPostingByAuhtorId(authorId: string) {
|
||||
export async function forum_getAllPostingByAuhtorId({
|
||||
authorId,
|
||||
page,
|
||||
}: {
|
||||
authorId: string;
|
||||
page: any;
|
||||
}) {
|
||||
const takeData = 5;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
const get = await prisma.forum_Posting.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
@@ -22,7 +33,13 @@ export async function forum_getListPostingByAuhtorId(authorId: string) {
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
Profile: true,
|
||||
username: true,
|
||||
Profile: {
|
||||
select: {
|
||||
id: true,
|
||||
imagesId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Forum_Komentar: {
|
||||
@@ -30,14 +47,20 @@ export async function forum_getListPostingByAuhtorId(authorId: string) {
|
||||
isActive: true,
|
||||
},
|
||||
},
|
||||
ForumMaster_StatusPosting: true
|
||||
ForumMaster_StatusPosting: {
|
||||
select: {
|
||||
id: true,
|
||||
status: true,
|
||||
},
|
||||
},
|
||||
forumMaster_StatusPostingId: true,
|
||||
},
|
||||
});
|
||||
|
||||
const data = get.map((val) => ({
|
||||
..._.omit(val, ["Forum_Komentar"]),
|
||||
_count: val.Forum_Komentar.length,
|
||||
}));
|
||||
// const data = get.map((val) => ({
|
||||
// ..._.omit(val, ["Forum_Komentar"]),
|
||||
// _count: val.Forum_Komentar.length,
|
||||
// }));
|
||||
|
||||
return data;
|
||||
return get;
|
||||
}
|
||||
|
||||
@@ -13,5 +13,5 @@ export default async function forum_getOneKategoriById({
|
||||
},
|
||||
});
|
||||
|
||||
return cekData
|
||||
return cekData;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import _ from "lodash";
|
||||
|
||||
export default async function forum_funGetOneReportedPostingById({
|
||||
postingId,
|
||||
}: {
|
||||
postingId: string;
|
||||
}) {
|
||||
const data = await prisma.forum_Posting.findFirst({
|
||||
where: {
|
||||
id: postingId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
diskusi: true,
|
||||
Forum_ReportPosting: {
|
||||
select: {
|
||||
id: true,
|
||||
deskripsi: true,
|
||||
forumMaster_KategoriReportId: true,
|
||||
ForumMaster_KategoriReport: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// console.log(data)
|
||||
|
||||
const group = _.groupBy(
|
||||
data?.Forum_ReportPosting,
|
||||
(val) => val.ForumMaster_KategoriReport?.title
|
||||
);
|
||||
const getKey = _.keys(group);
|
||||
const filterGroup = getKey.map((e) => e.replace("undefined", "Lainnya"));
|
||||
|
||||
const allData = {
|
||||
data: data,
|
||||
list: filterGroup,
|
||||
};
|
||||
|
||||
// console.log(allData);
|
||||
|
||||
return allData;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import _ from "lodash";
|
||||
import { MODEL_FORUM_KOMENTAR } from "../../model/interface";
|
||||
import { group } from "console";
|
||||
|
||||
export default async function forum_funGetOneReportKomentarById({
|
||||
komentarId,
|
||||
}: {
|
||||
komentarId: string;
|
||||
}) {
|
||||
const data = await prisma.forum_Komentar.findFirst({
|
||||
where: {
|
||||
id: komentarId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
komentar: true,
|
||||
Forum_Posting: {
|
||||
select: {
|
||||
id: true,
|
||||
diskusi: true,
|
||||
Author: {
|
||||
select: {
|
||||
username: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Forum_ReportKomentar: {
|
||||
select: {
|
||||
deskripsi: true,
|
||||
ForumMaster_KategoriReport: {
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const group = _.groupBy(
|
||||
data?.Forum_ReportKomentar,
|
||||
(v) => v.ForumMaster_KategoriReport?.title
|
||||
);
|
||||
|
||||
const getKey = _.keys(group);
|
||||
const filterGroup = getKey.map((e) => e.replace("undefined", "Lainnya"));
|
||||
|
||||
const allData = {
|
||||
data: data,
|
||||
list: filterGroup,
|
||||
};
|
||||
|
||||
return allData;
|
||||
}
|
||||
Reference in New Issue
Block a user