fix admin forum

deskripsi
- fix pagination
This commit is contained in:
2025-05-05 14:41:04 +08:00
parent 9e66441cd0
commit d113dfc45a
5 changed files with 17 additions and 15 deletions

View File

@@ -18,7 +18,6 @@ export default async function Page({ params }: { params: { id: string } }) {
return (
<>
<AdminForum_LihatSemuaKomentar
dataPosting={dataPosting as any}
/>
</>

View File

@@ -1,9 +1,6 @@
import { AdminForum_TableReportPosting } from "@/app_modules/admin/forum";
import adminForum_funGetAllReportPosting from "@/app_modules/admin/forum/fun/get/get_all_report_posting";
export default async function Page() {
return (
<>
<AdminForum_TableReportPosting />

View File

@@ -53,13 +53,13 @@ export default function AdminForum_DetailPosting({
<Admin_V3_ComponentBreakpoint>
<ComponentAdminForum_ViewOneDetailPosting dataPosting={dataPosting} />
</Admin_V3_ComponentBreakpoint>
<TableKomentar postingId={dataPosting.id} />
<TableKomentar postingId={dataPosting.id} totalComments={dataPosting.Forum_Komentar as any} />
</Stack>
</>
);
}
function TableKomentar({ postingId }: { postingId: string }) {
function TableKomentar({ postingId, totalComments }: { postingId: string, totalComments: number }) {
const router = useRouter();
const [data, setData] = useState<MODEL_FORUM_KOMENTAR[] | null>(null);
const [nPage, setNPage] = useState<number>(1);
@@ -84,7 +84,7 @@ function TableKomentar({ postingId }: { postingId: string }) {
if (response && response.success) {
setData(response.data.data);
setDelete(false);
setNPage(response.data.nCount || 1);
setNPage(response.data.nPage || 1);
}
} catch (error) {
console.error("Invalid data format received:", error);
@@ -201,7 +201,7 @@ function TableKomentar({ postingId }: { postingId: string }) {
Komentar:
</Title>
<Title order={4} c={"white"}>
{data?.length}
{totalComments}
</Title>
</Group>
}

View File

@@ -1,6 +1,7 @@
"use server";
import prisma from "@/lib/prisma";
import _ from "lodash";
export async function adminForum_getOnePostingById(postingId: string) {
const data = await prisma.forum_Posting.findFirst({
@@ -28,10 +29,18 @@ export async function adminForum_getOnePostingById(postingId: string) {
},
},
},
Forum_Komentar: {
where: {
isActive: true
}
}
},
});
// console.log(data);
const result = {
..._.omit(data, "Forum_Komentar"),
Forum_Komentar: data?.Forum_Komentar.length,
};
return data;
return result;
}

View File

@@ -8,16 +8,14 @@ import { RouterAdminForum } from "@/lib/router_admin/router_admin_forum";
import { clientLogger } from "@/util/clientLogger";
import {
Badge,
Box,
Button,
Center,
Paper,
ScrollArea,
Spoiler,
Stack,
Table,
Text,
TextInput,
TextInput
} from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { IconFlag3, IconSearch } from "@tabler/icons-react";
@@ -25,8 +23,8 @@ import { useRouter } from "next/navigation";
import { useState } from "react";
import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component";
import { Admin_V3_ComponentPaginationBreakpoint } from "../../_components_v3/comp_pagination_breakpoint";
import { apiGetAdminForumReportPosting } from "../lib/api_fetch_admin_forum";
import { AdminForum_CompTableSetHtmlStiker } from "../component/comp_table_set_html_stiker";
import { apiGetAdminForumReportPosting } from "../lib/api_fetch_admin_forum";
export default function AdminForum_TableReportPosting() {
return (
@@ -34,7 +32,6 @@ export default function AdminForum_TableReportPosting() {
<Stack>
<ComponentAdminGlobal_HeaderTamplate name="Forum" />
<TableView />
{/* <pre>{JSON.stringify(listPublish, null, 2)}</pre> */}
</Stack>
</>
);