Notifikasi Forum

# feat
- Notif jika ada postingan baru
## No issue
This commit is contained in:
2024-06-13 16:48:42 +08:00
parent 3b11b30473
commit edd13ffe0f
15 changed files with 943 additions and 71 deletions

View File

@@ -15,7 +15,7 @@ export async function forum_funCreate(value: string) {
},
});
if (!create) return { status: 400, message: "Gagal menambahkan postingan" };
if (!create) return { status: 400, message: "Gagal memposting" };
revalidatePath("/dev/forum/main");
return { status: 201, message: "Berhasil menambahkan postingan" };
return { status: 201, message: "Berhasil memposting" };
}

View File

@@ -0,0 +1,75 @@
"use server";
import _, { ceil } from "lodash";
import prisma from "@/app/lib/prisma";
import { forum_countOneTotalKomentarById } from "../count/count_one_total_komentar_by_id";
import { forum_countTotalKomenById } from "../count/count_total_komentar_by_id";
export async function forum_new_getAllPosting({
page,
search,
}: {
page: number;
search?: string;
}) {
const takeData = 10;
const skipData = page * takeData - takeData;
const getData = await prisma.forum_Posting.findMany({
take: takeData,
skip: skipData,
orderBy: {
createdAt: "desc",
},
where: {
isActive: true,
diskusi: {
mode: "insensitive",
contains: search,
},
},
select: {
id: true,
diskusi: true,
createdAt: true,
isActive: true,
authorId: true,
Author: {
select: {
id: true,
username: true,
Profile: {
select: {
id: true,
imagesId: true,
},
},
},
},
Forum_Komentar: {
where: {
isActive: true,
},
},
ForumMaster_StatusPosting: true,
},
});
const nCount = await prisma.forum_Posting.count({
where: {
isActive: true,
diskusi: {
mode: "insensitive",
contains: search,
},
},
});
const allData = {
data: getData,
nPage: ceil(nCount / takeData),
};
return allData;
}

View File

@@ -0,0 +1,48 @@
"use server"
import prisma from "@/app/lib/prisma";
export default async function forum_v2_getAllPosting({search}: {search?: string}) {
const getData = await prisma.forum_Posting.findMany({
// take: takeData,
// skip: skipData,
orderBy: {
createdAt: "desc",
},
where: {
isActive: true,
diskusi: {
mode: "insensitive",
contains: search,
},
},
select: {
id: true,
diskusi: true,
createdAt: true,
isActive: true,
authorId: true,
Author: {
select: {
id: true,
username: true,
Profile: {
select: {
id: true,
imagesId: true,
},
},
},
},
Forum_Komentar: {
where: {
isActive: true,
},
},
ForumMaster_StatusPosting: true,
},
});
return getData
}