Notifikasi Forum
# feat - Notif jika ada postingan baru ## No issue
This commit is contained in:
@@ -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" };
|
||||
}
|
||||
|
||||
75
src/app_modules/forum/fun/get/new_get_all_posting.ts
Normal file
75
src/app_modules/forum/fun/get/new_get_all_posting.ts
Normal 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;
|
||||
}
|
||||
48
src/app_modules/forum/fun/get/v2_get_all_posting.ts
Normal file
48
src/app_modules/forum/fun/get/v2_get_all_posting.ts
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user