fix admin forum
deskripsi - fix pagination
This commit is contained in:
@@ -18,7 +18,6 @@ export default async function Page({ params }: { params: { id: string } }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AdminForum_LihatSemuaKomentar
|
<AdminForum_LihatSemuaKomentar
|
||||||
|
|
||||||
dataPosting={dataPosting as any}
|
dataPosting={dataPosting as any}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import { AdminForum_TableReportPosting } from "@/app_modules/admin/forum";
|
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() {
|
export default async function Page() {
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AdminForum_TableReportPosting />
|
<AdminForum_TableReportPosting />
|
||||||
|
|||||||
@@ -53,13 +53,13 @@ export default function AdminForum_DetailPosting({
|
|||||||
<Admin_V3_ComponentBreakpoint>
|
<Admin_V3_ComponentBreakpoint>
|
||||||
<ComponentAdminForum_ViewOneDetailPosting dataPosting={dataPosting} />
|
<ComponentAdminForum_ViewOneDetailPosting dataPosting={dataPosting} />
|
||||||
</Admin_V3_ComponentBreakpoint>
|
</Admin_V3_ComponentBreakpoint>
|
||||||
<TableKomentar postingId={dataPosting.id} />
|
<TableKomentar postingId={dataPosting.id} totalComments={dataPosting.Forum_Komentar as any} />
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function TableKomentar({ postingId }: { postingId: string }) {
|
function TableKomentar({ postingId, totalComments }: { postingId: string, totalComments: number }) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [data, setData] = useState<MODEL_FORUM_KOMENTAR[] | null>(null);
|
const [data, setData] = useState<MODEL_FORUM_KOMENTAR[] | null>(null);
|
||||||
const [nPage, setNPage] = useState<number>(1);
|
const [nPage, setNPage] = useState<number>(1);
|
||||||
@@ -84,7 +84,7 @@ function TableKomentar({ postingId }: { postingId: string }) {
|
|||||||
if (response && response.success) {
|
if (response && response.success) {
|
||||||
setData(response.data.data);
|
setData(response.data.data);
|
||||||
setDelete(false);
|
setDelete(false);
|
||||||
setNPage(response.data.nCount || 1);
|
setNPage(response.data.nPage || 1);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Invalid data format received:", error);
|
console.error("Invalid data format received:", error);
|
||||||
@@ -201,7 +201,7 @@ function TableKomentar({ postingId }: { postingId: string }) {
|
|||||||
Komentar:
|
Komentar:
|
||||||
</Title>
|
</Title>
|
||||||
<Title order={4} c={"white"}>
|
<Title order={4} c={"white"}>
|
||||||
{data?.length}
|
{totalComments}
|
||||||
</Title>
|
</Title>
|
||||||
</Group>
|
</Group>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
|
import _ from "lodash";
|
||||||
|
|
||||||
export async function adminForum_getOnePostingById(postingId: string) {
|
export async function adminForum_getOnePostingById(postingId: string) {
|
||||||
const data = await prisma.forum_Posting.findFirst({
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,16 +8,14 @@ import { RouterAdminForum } from "@/lib/router_admin/router_admin_forum";
|
|||||||
import { clientLogger } from "@/util/clientLogger";
|
import { clientLogger } from "@/util/clientLogger";
|
||||||
import {
|
import {
|
||||||
Badge,
|
Badge,
|
||||||
Box,
|
|
||||||
Button,
|
Button,
|
||||||
Center,
|
Center,
|
||||||
Paper,
|
Paper,
|
||||||
ScrollArea,
|
ScrollArea,
|
||||||
Spoiler,
|
|
||||||
Stack,
|
Stack,
|
||||||
Table,
|
Table,
|
||||||
Text,
|
Text,
|
||||||
TextInput,
|
TextInput
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import { IconFlag3, IconSearch } from "@tabler/icons-react";
|
import { IconFlag3, IconSearch } from "@tabler/icons-react";
|
||||||
@@ -25,8 +23,8 @@ import { useRouter } from "next/navigation";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component";
|
import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component";
|
||||||
import { Admin_V3_ComponentPaginationBreakpoint } from "../../_components_v3/comp_pagination_breakpoint";
|
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 { AdminForum_CompTableSetHtmlStiker } from "../component/comp_table_set_html_stiker";
|
||||||
|
import { apiGetAdminForumReportPosting } from "../lib/api_fetch_admin_forum";
|
||||||
|
|
||||||
export default function AdminForum_TableReportPosting() {
|
export default function AdminForum_TableReportPosting() {
|
||||||
return (
|
return (
|
||||||
@@ -34,7 +32,6 @@ export default function AdminForum_TableReportPosting() {
|
|||||||
<Stack>
|
<Stack>
|
||||||
<ComponentAdminGlobal_HeaderTamplate name="Forum" />
|
<ComponentAdminGlobal_HeaderTamplate name="Forum" />
|
||||||
<TableView />
|
<TableView />
|
||||||
{/* <pre>{JSON.stringify(listPublish, null, 2)}</pre> */}
|
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user