Fix tampilan admin dan notifikasi to admin
# fix - Notifikasi report posting _ Realtime notifikasi ## Issuee: Cooming soon saat report komentar langsung menuju tablenya
This commit is contained in:
@@ -1,288 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { RouterAdminForum } from "@/app/lib/router_admin/router_admin_forum";
|
||||
import { RouterForum } from "@/app/lib/router_hipmi/router_forum";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component_global/header_tamplate";
|
||||
import { MODEL_FORUM_POSTING } from "@/app_modules/forum/model/interface";
|
||||
import {
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
Group,
|
||||
Modal,
|
||||
ScrollArea,
|
||||
Spoiler,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { IconMessageCircle } from "@tabler/icons-react";
|
||||
import { IconFlag3 } from "@tabler/icons-react";
|
||||
import { IconEyeCheck, IconTrash } from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { adminForum_funDeletePostingById } from "../../fun/delete/fun_delete_posting_by_id";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
|
||||
export default function AdminForum_TablePublish({
|
||||
listPublish,
|
||||
}: {
|
||||
listPublish: MODEL_FORUM_POSTING[];
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Forum: Table Posting" />
|
||||
<TablePublish listPublish={listPublish} />
|
||||
{/* <pre>{JSON.stringify(listPublish, null, 2)}</pre> */}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function TablePublish({ listPublish }: { listPublish: MODEL_FORUM_POSTING[] }) {
|
||||
const router = useRouter();
|
||||
// const [data, setData] = useState(listPublish);
|
||||
|
||||
const TableRows = listPublish?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text lineClamp={1}>{e?.Author?.Profile?.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={100}>
|
||||
<Badge
|
||||
color={
|
||||
(e?.ForumMaster_StatusPosting?.id as any) === 1 ? "green" : "red"
|
||||
}
|
||||
>
|
||||
{e?.ForumMaster_StatusPosting?.status}
|
||||
</Badge>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={400}>
|
||||
<Spoiler
|
||||
// w={400}
|
||||
maxHeight={60}
|
||||
hideLabel="sembunyikan"
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
<div dangerouslySetInnerHTML={{ __html: e.diskusi }} />
|
||||
</Spoiler>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Text>
|
||||
{new Intl.DateTimeFormat(["id-ID"], { dateStyle: "medium" }).format(
|
||||
e.createdAt
|
||||
)}
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Text fw={"bold"} fz={"lg"}>
|
||||
{e?.Forum_Komentar.length}
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Text
|
||||
c={e?.Forum_ReportPosting?.length >= 3 ? "red" : "black"}
|
||||
fw={"bold"}
|
||||
fz={"lg"}
|
||||
>
|
||||
{e?.Forum_ReportPosting.length}
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Stack align="center" spacing={"xs"}>
|
||||
<ButtonAction postingId={e?.id} />
|
||||
<ButtonDeletePosting postingId={e?.id} />
|
||||
</Stack>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box>
|
||||
<Box bg={"green.1"} p={"xs"}>
|
||||
<Title order={6} c={"green"}>
|
||||
POSTING
|
||||
</Title>
|
||||
</Box>
|
||||
<ScrollArea w={"100%"}>
|
||||
<Table
|
||||
withBorder
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"xl"}
|
||||
p={"md"}
|
||||
striped
|
||||
highlightOnHover
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center>Author</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Status</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Postingan</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tanggal Publish</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Komentar Aktif</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Total Report Posting</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{TableRows}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
|
||||
<Center>
|
||||
{_.isEmpty(TableRows) ? (
|
||||
<Center h={"50vh"}>
|
||||
<Title order={6}>Tidak Ada Data</Title>
|
||||
</Center>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</Center>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonAction({ postingId }: { postingId: string }) {
|
||||
const router = useRouter();
|
||||
const [loadingKomentar, setLoadingKomentar] = useState(false);
|
||||
const [loadingReport, setLoadingReport] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
loading={loadingKomentar ? true : false}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
w={150}
|
||||
compact
|
||||
leftIcon={<IconMessageCircle size={15} />}
|
||||
onClick={() => {
|
||||
setLoadingKomentar(true);
|
||||
router.push(RouterAdminForum.semua_komentar + postingId);
|
||||
}}
|
||||
>
|
||||
Lihat Komentar
|
||||
</Button>
|
||||
<Button
|
||||
loading={loadingReport ? true : false}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
w={150}
|
||||
compact
|
||||
leftIcon={<IconFlag3 size={15} />}
|
||||
onClick={() => {
|
||||
setLoadingReport(true);
|
||||
router.push(RouterAdminForum.hasil_report_posting + postingId);
|
||||
}}
|
||||
>
|
||||
Hasil Report
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonDeletePosting({ postingId }: { postingId: string }) {
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [loadingDel, setLoadingDel] = useState(false);
|
||||
const [loadingDel2, setLoadingDel2] = useState(false);
|
||||
|
||||
async function onDelete() {
|
||||
await adminForum_funDeletePostingById(postingId).then((res) => {
|
||||
if (res.status === 200) {
|
||||
setLoadingDel2(false);
|
||||
setLoadingDel(false);
|
||||
close();
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Modal
|
||||
opened={opened}
|
||||
onClose={close}
|
||||
centered
|
||||
withCloseButton={false}
|
||||
closeOnClickOutside={false}
|
||||
>
|
||||
<Stack>
|
||||
<Title order={5}>Anda yakin menghapus posting ini</Title>
|
||||
<Group position="center">
|
||||
<Button
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
close();
|
||||
setLoadingDel(false);
|
||||
}}
|
||||
>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={loadingDel2 ? true : false}
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
onClick={() => {
|
||||
onDelete();
|
||||
setLoadingDel2(true);
|
||||
}}
|
||||
>
|
||||
Hapus
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={loadingDel ? true : false}
|
||||
radius={"xl"}
|
||||
w={150}
|
||||
compact
|
||||
color="red"
|
||||
leftIcon={<IconTrash size={15} />}
|
||||
onClick={() => {
|
||||
// onDelete();
|
||||
open();
|
||||
setLoadingDel(true);
|
||||
}}
|
||||
>
|
||||
Hapus Posting
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Stack } from "@mantine/core";
|
||||
|
||||
export default function AdminForum_TableReportKomentar() {
|
||||
return (
|
||||
<>
|
||||
<Stack>ini rep komen</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { Stack } from "@mantine/core";
|
||||
|
||||
export default function AdminForum_TableReportPosting() {
|
||||
return (
|
||||
<>
|
||||
<Stack>ini rep pos</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,291 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { RouterAdminForum } from "@/app/lib/router_admin/router_admin_forum";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component_global/header_tamplate";
|
||||
import ComponentAdminDonasi_TombolKembali from "@/app_modules/admin/donasi/component/tombol_kembali";
|
||||
import {
|
||||
MODEL_FORUM_KOMENTAR,
|
||||
MODEL_FORUM_POSTING,
|
||||
} from "@/app_modules/forum/model/interface";
|
||||
import {
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
Grid,
|
||||
Group,
|
||||
Modal,
|
||||
Paper,
|
||||
ScrollArea,
|
||||
Spoiler,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { IconTrash } from "@tabler/icons-react";
|
||||
import { IconFlag3 } from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { adminForum_funDeleteKomentarById } from "../../fun/delete/fun_delete_komentar_by_id";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
|
||||
export default function AdminForum_LihatSemuaKomentar({
|
||||
listKomentar,
|
||||
dataPosting,
|
||||
}: {
|
||||
listKomentar: MODEL_FORUM_KOMENTAR[];
|
||||
dataPosting: MODEL_FORUM_POSTING;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
{/* <pre>{JSON.stringify(listKomentar, null, 2)}</pre> */}
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Forum: Komentar" />
|
||||
<ComponentAdminDonasi_TombolKembali />
|
||||
<DataPosting dataPosting={dataPosting} />
|
||||
<TableKomentar listKomentar={listKomentar} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function DataPosting({ dataPosting }: { dataPosting: MODEL_FORUM_POSTING }) {
|
||||
return (
|
||||
<>
|
||||
<Stack w={"50%"}>
|
||||
<Box>
|
||||
<Box bg={"green.1"} p={"xs"}>
|
||||
<Title order={6} c={"green"}>
|
||||
POSTING
|
||||
</Title>
|
||||
</Box>
|
||||
<Paper withBorder p={"md"} radius={0}>
|
||||
<Stack spacing={0}>
|
||||
<Grid w={500} fw={"bold"}>
|
||||
<Grid.Col span={"content"}>
|
||||
<Text>Author :</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Text lineClamp={1}>
|
||||
{dataPosting?.Author?.Profile?.name}
|
||||
</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.Col span={"content"}>
|
||||
<Spoiler
|
||||
w={500}
|
||||
hideLabel="sembunyikan"
|
||||
maxHeight={100}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
<div
|
||||
dangerouslySetInnerHTML={{ __html: dataPosting.diskusi }}
|
||||
/>
|
||||
</Spoiler>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Stack>
|
||||
</Paper>
|
||||
</Box>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function TableKomentar({
|
||||
listKomentar,
|
||||
}: {
|
||||
listKomentar: MODEL_FORUM_KOMENTAR[];
|
||||
}) {
|
||||
const router = useRouter();
|
||||
// const [data, setData] = useState(listKomentar);
|
||||
|
||||
const TableRows = listKomentar?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={"100%"}>
|
||||
<Text truncate>{e?.Author?.Profile?.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Spoiler
|
||||
w={400}
|
||||
maxHeight={50}
|
||||
hideLabel="sembunyikan"
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
<div
|
||||
style={{ textAlign: "center" }}
|
||||
dangerouslySetInnerHTML={{ __html: e.komentar }}
|
||||
/>
|
||||
</Spoiler>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Text w={100}>
|
||||
{new Intl.DateTimeFormat(["id-ID"], { dateStyle: "medium" }).format(
|
||||
e.createdAt
|
||||
)}
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Text
|
||||
c={e?.Forum_ReportKomentar?.length >= 3 ? "red" : "black"}
|
||||
fw={"bold"}
|
||||
fz={"lg"}
|
||||
>
|
||||
{e?.Forum_ReportKomentar.length}
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Stack align="center" spacing={"xs"}>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
w={150}
|
||||
compact
|
||||
leftIcon={<IconFlag3 size={15} />}
|
||||
onClick={() =>
|
||||
router.push(RouterAdminForum.hasil_report_komentar + e?.id)
|
||||
}
|
||||
>
|
||||
Hasil Report
|
||||
</Button>
|
||||
<ButtonDeleteKomentar komentarId={e?.id} />
|
||||
</Stack>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box>
|
||||
<Box bg={"gray.1"} p={"xs"}>
|
||||
<Title order={6} c={"gray"}>
|
||||
KOMENTAR
|
||||
</Title>
|
||||
</Box>
|
||||
<ScrollArea w={"100%"}>
|
||||
<Table
|
||||
withBorder
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"xl"}
|
||||
p={"md"}
|
||||
striped
|
||||
highlightOnHover
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center>Author</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Komentar</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tanggal Komentar</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Total Report Komentar</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{TableRows}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
|
||||
<Center>
|
||||
{_.isEmpty(TableRows) ? (
|
||||
<Center h={"50vh"}>
|
||||
<Title order={6}>Tidak Ada Data</Title>
|
||||
</Center>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</Center>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonDeleteKomentar({ komentarId }: { komentarId: string }) {
|
||||
const router = useRouter();
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [loadindDel, setLoadingDel] = useState(false);
|
||||
const [loadingDel2, setLoadingDel2] = useState(false);
|
||||
|
||||
async function onDelete() {
|
||||
await adminForum_funDeleteKomentarById(komentarId).then((res) => {
|
||||
if (res.status === 200) {
|
||||
setLoadingDel(false);
|
||||
setLoadingDel2(false);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
close();
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Modal opened={opened} onClose={close} centered withCloseButton={false}>
|
||||
<Stack>
|
||||
<Title order={5}>Anda yakin menghapus komentar ini ?</Title>
|
||||
<Group position="center">
|
||||
<Button
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
close();
|
||||
setLoadingDel(false);
|
||||
}}
|
||||
>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={loadingDel2 ? true : false}
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
onClick={() => {
|
||||
onDelete();
|
||||
setLoadingDel2(true);
|
||||
}}
|
||||
>
|
||||
Hapus
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal>
|
||||
|
||||
<Button
|
||||
loading={loadindDel ? true : false}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
w={150}
|
||||
fz={"xs"}
|
||||
compact
|
||||
color="red"
|
||||
leftIcon={<IconTrash size={15} />}
|
||||
onClick={() => {
|
||||
open();
|
||||
setLoadingDel(true);
|
||||
}}
|
||||
>
|
||||
Hapus Komentar
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
84
src/app_modules/admin/forum/component/button_delete.tsx
Normal file
84
src/app_modules/admin/forum/component/button_delete.tsx
Normal file
@@ -0,0 +1,84 @@
|
||||
"use client";
|
||||
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { Modal, Stack, Title, Group, Button } from "@mantine/core";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { IconTrash } from "@tabler/icons-react";
|
||||
import { useState } from "react";
|
||||
import { adminForum_funDeletePostingById } from "../fun/delete/fun_delete_posting_by_id";
|
||||
|
||||
export default function ComponentAdminForum_ButtonDeletePosting({
|
||||
postingId,
|
||||
onSuccesDelete,
|
||||
}: {
|
||||
postingId: string;
|
||||
onSuccesDelete: (val: any) => void;
|
||||
}) {
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [loadingDel2, setLoadingDel2] = useState(false);
|
||||
|
||||
async function onDelete() {
|
||||
await adminForum_funDeletePostingById(postingId).then((res) => {
|
||||
if (res.status === 200) {
|
||||
setLoadingDel2(false);
|
||||
close();
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
onSuccesDelete(true);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Modal
|
||||
opened={opened}
|
||||
onClose={close}
|
||||
centered
|
||||
withCloseButton={false}
|
||||
closeOnClickOutside={false}
|
||||
>
|
||||
<Stack>
|
||||
<Title order={5}>Anda yakin menghapus posting ini</Title>
|
||||
<Group position="center">
|
||||
<Button
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
close();
|
||||
}}
|
||||
>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={loadingDel2 ? true : false}
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
onClick={() => {
|
||||
onDelete();
|
||||
setLoadingDel2(true);
|
||||
}}
|
||||
>
|
||||
Hapus
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal>
|
||||
<Button
|
||||
fz={"xs"}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
w={170}
|
||||
color="red"
|
||||
leftIcon={<IconTrash size={15} />}
|
||||
onClick={() => {
|
||||
// onDelete();
|
||||
open();
|
||||
}}
|
||||
>
|
||||
Hapus Posting
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
73
src/app_modules/admin/forum/component/detail_one_posting.tsx
Normal file
73
src/app_modules/admin/forum/component/detail_one_posting.tsx
Normal file
@@ -0,0 +1,73 @@
|
||||
"use client";
|
||||
|
||||
import { MODEL_FORUM_POSTING } from "@/app_modules/forum/model/interface";
|
||||
import {
|
||||
Badge,
|
||||
Box,
|
||||
Divider,
|
||||
Group,
|
||||
Paper,
|
||||
Spoiler,
|
||||
Stack,
|
||||
Text,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
|
||||
export default function ComponentAdminForum_ViewOneDetailPosting({
|
||||
dataPosting,
|
||||
}: {
|
||||
dataPosting: MODEL_FORUM_POSTING;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xs"} h={"100%"} w={"50%"}>
|
||||
<Paper bg={"green.4"} p={"xs"} style={{ borderRadius: "6px" }}>
|
||||
<Title order={4} c={"white"}>
|
||||
Detail Posting
|
||||
</Title>
|
||||
</Paper>
|
||||
|
||||
<Paper withBorder p={"md"} radius={"md"} shadow="sm">
|
||||
<Stack>
|
||||
<Stack spacing={5}>
|
||||
<Group position="apart">
|
||||
<Text>
|
||||
Username:{" "}
|
||||
<Text span inherit fw={"bold"}>
|
||||
{dataPosting?.Author?.username}
|
||||
</Text>
|
||||
</Text>
|
||||
|
||||
<Badge
|
||||
color={
|
||||
(dataPosting?.ForumMaster_StatusPosting?.id as any) === 1
|
||||
? "green"
|
||||
: "red"
|
||||
}
|
||||
>
|
||||
{dataPosting?.ForumMaster_StatusPosting?.status}
|
||||
</Badge>
|
||||
</Group>
|
||||
<Divider />
|
||||
</Stack>
|
||||
|
||||
<Box>
|
||||
<Spoiler
|
||||
w={500}
|
||||
hideLabel="sembunyikan"
|
||||
maxHeight={100}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
<div
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: dataPosting?.diskusi,
|
||||
}}
|
||||
/>
|
||||
</Spoiler>
|
||||
</Box>
|
||||
</Stack>
|
||||
</Paper>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
316
src/app_modules/admin/forum/detail/detail_posting.tsx
Normal file
316
src/app_modules/admin/forum/detail/detail_posting.tsx
Normal file
@@ -0,0 +1,316 @@
|
||||
"use client";
|
||||
|
||||
import { RouterAdminForum } from "@/app/lib/router_admin/router_admin_forum";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component_global/header_tamplate";
|
||||
import ComponentAdminDonasi_TombolKembali from "@/app_modules/admin/donasi/component/tombol_kembali";
|
||||
import {
|
||||
MODEL_FORUM_KOMENTAR,
|
||||
MODEL_FORUM_POSTING,
|
||||
} from "@/app_modules/forum/model/interface";
|
||||
import {
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
Grid,
|
||||
Group,
|
||||
Modal,
|
||||
Pagination,
|
||||
Paper,
|
||||
ScrollArea,
|
||||
Spoiler,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
TextInput,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { IconSearch, IconTrash } from "@tabler/icons-react";
|
||||
import { IconFlag3 } from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { adminForum_funDeleteKomentarById } from "../fun/delete/fun_delete_komentar_by_id";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import ComponentAdminGlobal_IsEmptyData from "../../component_global/is_empty_data";
|
||||
import { adminForum_getListKomentarById } from "../fun/get/get_list_komentar_by_id";
|
||||
import ComponentAdminGlobal_BackButton from "../../component_global/back_button";
|
||||
import ComponentAdminForum_ViewOneDetailPosting from "../component/detail_one_posting";
|
||||
|
||||
export default function AdminForum_DetailPosting({
|
||||
listKomentar,
|
||||
dataPosting,
|
||||
countKomentar,
|
||||
}: {
|
||||
listKomentar: any;
|
||||
dataPosting: MODEL_FORUM_POSTING;
|
||||
countKomentar: number;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
{/* <pre>{JSON.stringify(listKomentar, null, 2)}</pre> */}
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Forum: Detail Posting" />
|
||||
<ComponentAdminGlobal_BackButton />
|
||||
<ComponentAdminForum_ViewOneDetailPosting dataPosting={dataPosting} />
|
||||
<TableKomentar
|
||||
listKomentar={listKomentar}
|
||||
postingId={dataPosting.id}
|
||||
countKomentar={countKomentar}
|
||||
/>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function TableKomentar({
|
||||
listKomentar,
|
||||
postingId,
|
||||
countKomentar,
|
||||
}: {
|
||||
listKomentar: any;
|
||||
postingId: string;
|
||||
countKomentar: number;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState<MODEL_FORUM_KOMENTAR[]>(listKomentar.data);
|
||||
const [nPage, setNPage] = useState(listKomentar.nPage);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isSearch, setSearch] = useState("");
|
||||
const [isLoadingReport, setLoadingReport] = useState(false);
|
||||
const [idData, setIdData] = useState("");
|
||||
|
||||
async function onSearch(s: string) {
|
||||
setSearch(s);
|
||||
setActivePage(1);
|
||||
const loadData = await adminForum_getListKomentarById({
|
||||
postingId: postingId,
|
||||
page: 1,
|
||||
search: s,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
}
|
||||
|
||||
async function onPageClick(p: any) {
|
||||
setActivePage(p);
|
||||
const loadData = await adminForum_getListKomentarById({
|
||||
postingId: postingId,
|
||||
search: isSearch,
|
||||
page: p,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
}
|
||||
|
||||
const rowTable = data?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text lineClamp={1}>{e?.Author?.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Box w={500}>
|
||||
<Spoiler maxHeight={50} hideLabel="sembunyikan" showLabel="tampilkan">
|
||||
<div
|
||||
style={{ textAlign: "center" }}
|
||||
dangerouslySetInnerHTML={{ __html: e?.komentar }}
|
||||
/>
|
||||
</Spoiler>
|
||||
</Box>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text>
|
||||
{new Intl.DateTimeFormat(["id-ID"], { dateStyle: "medium" }).format(
|
||||
e.createdAt
|
||||
)}
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={100}>
|
||||
<Text
|
||||
c={e?.Forum_ReportKomentar?.length >= 3 ? "red" : "black"}
|
||||
fw={"bold"}
|
||||
fz={"lg"}
|
||||
>
|
||||
{e?.Forum_ReportKomentar.length}
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Stack align="center" spacing={"xs"} w={200}>
|
||||
<Button
|
||||
disabled={e?.Forum_ReportKomentar.length <= 0 ? true : false}
|
||||
loaderPosition="center"
|
||||
loading={isLoadingReport && e?.id === idData ? true : false}
|
||||
radius={"xl"}
|
||||
w={170}
|
||||
fz={"xs"}
|
||||
leftIcon={<IconFlag3 size={15} />}
|
||||
onClick={() => {
|
||||
setIdData(e?.id);
|
||||
setLoadingReport(true);
|
||||
router.push(RouterAdminForum.report_komentar + e?.id);
|
||||
}}
|
||||
>
|
||||
Lihat Report
|
||||
</Button>
|
||||
<ButtonDeleteKomentar komentarId={e?.id} />
|
||||
</Stack>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
<Group
|
||||
position="apart"
|
||||
bg={"gray"}
|
||||
p={"xs"}
|
||||
style={{ borderRadius: "6px" }}
|
||||
>
|
||||
<Group spacing={5}>
|
||||
<Title order={4} c={"white"}>
|
||||
Komentar
|
||||
</Title>
|
||||
<Title order={4} c={"white"}>
|
||||
{`(${countKomentar})`}
|
||||
</Title>
|
||||
</Group>
|
||||
<TextInput
|
||||
icon={<IconSearch size={20} />}
|
||||
radius={"xl"}
|
||||
placeholder="Cari komentar"
|
||||
onChange={(val) => {
|
||||
onSearch(val.currentTarget.value);
|
||||
}}
|
||||
/>
|
||||
</Group>
|
||||
|
||||
{_.isEmpty(data) ? (
|
||||
<ComponentAdminGlobal_IsEmptyData text="Tidak Ada Komentar" />
|
||||
) : (
|
||||
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"} offsetScrollbars>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={"100%"}
|
||||
h={"100%"}
|
||||
striped
|
||||
highlightOnHover
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center w={200}>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center w={500}>Komentar</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center w={200}>Tgl Komentar</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center w={100}>Total Report</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center w={200}>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{rowTable}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={activePage}
|
||||
total={nPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</Paper>
|
||||
)}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonDeleteKomentar({ komentarId }: { komentarId: string }) {
|
||||
const router = useRouter();
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [loadindDel, setLoadingDel] = useState(false);
|
||||
const [loadingDel2, setLoadingDel2] = useState(false);
|
||||
|
||||
async function onDelete() {
|
||||
await adminForum_funDeleteKomentarById(komentarId).then((res) => {
|
||||
if (res.status === 200) {
|
||||
setLoadingDel(false);
|
||||
setLoadingDel2(false);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
close();
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Modal opened={opened} onClose={close} centered withCloseButton={false}>
|
||||
<Stack>
|
||||
<Title order={5}>Anda yakin menghapus komentar ini ?</Title>
|
||||
<Group position="center">
|
||||
<Button
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
close();
|
||||
setLoadingDel(false);
|
||||
}}
|
||||
>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={loadingDel2 ? true : false}
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
onClick={() => {
|
||||
onDelete();
|
||||
setLoadingDel2(true);
|
||||
}}
|
||||
>
|
||||
Hapus
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal>
|
||||
|
||||
<Button
|
||||
loading={loadindDel ? true : false}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
w={170}
|
||||
color="red"
|
||||
fz={"xs"}
|
||||
leftIcon={<IconTrash size={15} />}
|
||||
onClick={() => {
|
||||
open();
|
||||
setLoadingDel(true);
|
||||
}}
|
||||
>
|
||||
Hapus Komentar
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export default async function adminForum_countKomentarByPostingId({
|
||||
postingId,
|
||||
}: {
|
||||
postingId: string;
|
||||
}) {
|
||||
const count = await prisma.forum_Komentar.count({
|
||||
where: {
|
||||
isActive: true,
|
||||
forum_PostingId: postingId,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
return count;
|
||||
}
|
||||
@@ -14,6 +14,5 @@ export async function adminForum_funDeleteKomentarById(komentarId: string) {
|
||||
});
|
||||
|
||||
if (!delTemporary) return { status: 400, message: "Gagal Dihapus" };
|
||||
revalidatePath("/dev/admin/forum/children/semua-komentar");
|
||||
return { status: 200, message: "Berhasil Dihapus" };
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { ceil } from "lodash";
|
||||
|
||||
export default async function adminForum_funGetAllReportPosting({
|
||||
page,
|
||||
search,
|
||||
}: {
|
||||
page: number;
|
||||
search?: string;
|
||||
}) {
|
||||
|
||||
const takeData = 10
|
||||
const skipData = page * takeData - takeData
|
||||
|
||||
const data = await prisma.forum_ReportPosting.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
Forum_Posting: {
|
||||
isActive: true,
|
||||
diskusi: {
|
||||
contains: search,
|
||||
mode: "insensitive"
|
||||
}
|
||||
},
|
||||
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
isActive: true,
|
||||
createdAt: true,
|
||||
deskripsi: true,
|
||||
forumMaster_KategoriReportId: true,
|
||||
ForumMaster_KategoriReport: {
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
deskripsi: true,
|
||||
},
|
||||
},
|
||||
|
||||
forum_PostingId: true,
|
||||
Forum_Posting: {
|
||||
select: {
|
||||
id: true,
|
||||
diskusi: true,
|
||||
ForumMaster_StatusPosting: {
|
||||
select: {
|
||||
id: true,
|
||||
status: true,
|
||||
}
|
||||
},
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
userId: true,
|
||||
User: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
const nCount = await prisma.forum_ReportPosting.count({
|
||||
where: {
|
||||
Forum_Posting: {
|
||||
isActive: true,
|
||||
diskusi: {
|
||||
contains: search,
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const allData = {
|
||||
data: data,
|
||||
nPage: ceil(nCount / takeData),
|
||||
};
|
||||
|
||||
return allData;
|
||||
}
|
||||
@@ -1,15 +1,33 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { ceil } from "lodash";
|
||||
|
||||
export async function adminForum_getListKomentarById({
|
||||
postingId,
|
||||
page,
|
||||
search,
|
||||
}: {
|
||||
postingId: string;
|
||||
page: number;
|
||||
search?: string;
|
||||
}) {
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
export async function adminForum_getListKomentarById(postingId: string) {
|
||||
const data = await prisma.forum_Komentar.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
forum_PostingId: postingId,
|
||||
isActive: true,
|
||||
komentar: {
|
||||
contains: search,
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
@@ -20,6 +38,7 @@ export async function adminForum_getListKomentarById(postingId: string) {
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: {
|
||||
select: {
|
||||
name: true,
|
||||
@@ -28,9 +47,25 @@ export async function adminForum_getListKomentarById(postingId: string) {
|
||||
},
|
||||
},
|
||||
},
|
||||
Forum_ReportKomentar: true
|
||||
Forum_ReportKomentar: true,
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
const nCount = await prisma.forum_Komentar.count({
|
||||
where: {
|
||||
forum_PostingId: postingId,
|
||||
isActive: true,
|
||||
komentar: {
|
||||
contains: search,
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const allData = {
|
||||
data: data,
|
||||
nPage: ceil(nCount / takeData),
|
||||
};
|
||||
|
||||
return allData;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,30 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { ceil } from "lodash";
|
||||
|
||||
export async function adminForum_getListPosting({
|
||||
page,
|
||||
search,
|
||||
}: {
|
||||
page: number;
|
||||
search?: string;
|
||||
}) {
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
export async function adminForum_getListPublish() {
|
||||
const data = await prisma.forum_Posting.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
isActive: true,
|
||||
diskusi: {
|
||||
contains: search,
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
@@ -25,12 +41,27 @@ export async function adminForum_getListPublish() {
|
||||
Forum_ReportPosting: true,
|
||||
Forum_Komentar: {
|
||||
where: {
|
||||
isActive: true
|
||||
}
|
||||
isActive: true,
|
||||
},
|
||||
},
|
||||
ForumMaster_StatusPosting: true
|
||||
ForumMaster_StatusPosting: true,
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
const nCount = await prisma.forum_Posting.count({
|
||||
where: {
|
||||
isActive: true,
|
||||
diskusi: {
|
||||
contains: search,
|
||||
mode: "insensitive",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const allData = {
|
||||
data: data,
|
||||
nPage: ceil(nCount / takeData),
|
||||
};
|
||||
|
||||
return allData;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,26 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { ceil } from "lodash";
|
||||
|
||||
export async function adminForum_getListReportKomentarbyId({
|
||||
komentarId,
|
||||
page,
|
||||
search,
|
||||
}: {
|
||||
komentarId: string;
|
||||
page: number;
|
||||
search?: string;
|
||||
}) {
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
export async function adminForum_getListReportKomentarbyId(komentarId: string) {
|
||||
const data = await prisma.forum_ReportKomentar.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
createdAt: "desc"
|
||||
},
|
||||
where: {
|
||||
forum_KomentarId: komentarId,
|
||||
},
|
||||
@@ -26,5 +43,16 @@ export async function adminForum_getListReportKomentarbyId(komentarId: string) {
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
const nCount = await prisma.forum_ReportKomentar.count({
|
||||
where: {
|
||||
forum_KomentarId: komentarId,
|
||||
},
|
||||
});
|
||||
|
||||
const allData = {
|
||||
data: data,
|
||||
nPage: ceil(nCount / takeData)
|
||||
}
|
||||
|
||||
return allData;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,24 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { ceil } from "lodash";
|
||||
|
||||
export async function adminForum_getListReportPostingById({
|
||||
postingId,
|
||||
page,
|
||||
}: {
|
||||
postingId: string;
|
||||
page: number;
|
||||
}) {
|
||||
const takeData = 10;
|
||||
const skipData = page * takeData - takeData;
|
||||
|
||||
export async function adminForum_getListReportPostingById(postingId: string) {
|
||||
const data = await prisma.forum_ReportPosting.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
forum_PostingId: postingId,
|
||||
},
|
||||
@@ -13,6 +28,8 @@ export async function adminForum_getListReportPostingById(postingId: string) {
|
||||
createdAt: true,
|
||||
User: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: {
|
||||
select: {
|
||||
name: true,
|
||||
@@ -30,5 +47,16 @@ export async function adminForum_getListReportPostingById(postingId: string) {
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
const nCount = await prisma.forum_ReportPosting.count({
|
||||
where: {
|
||||
forum_PostingId: postingId,
|
||||
},
|
||||
});
|
||||
|
||||
const allData = {
|
||||
data: data,
|
||||
nPage: ceil(nCount / takeData),
|
||||
};
|
||||
|
||||
return allData;
|
||||
}
|
||||
|
||||
@@ -10,11 +10,19 @@ export async function adminForum_getOnePostingById(postingId: string) {
|
||||
select: {
|
||||
id: true,
|
||||
diskusi: true,
|
||||
ForumMaster_StatusPosting: {
|
||||
select: {
|
||||
id: true,
|
||||
status: true,
|
||||
},
|
||||
},
|
||||
Author: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: {
|
||||
select: {
|
||||
name: true
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -22,7 +30,7 @@ export async function adminForum_getOnePostingById(postingId: string) {
|
||||
},
|
||||
});
|
||||
|
||||
// console.log(data);
|
||||
// console.log(data);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
import AdminForum_Main from "./main";
|
||||
import AdminForum_TablePublish from "./child/publish";
|
||||
import AdminForum_TableReportKomentar from "./child/report_komentar";
|
||||
import AdminForum_TableReportPosting from "./child/report_posting";
|
||||
import AdminForum_LihatSemuaKomentar from "./children/semua_komentar";
|
||||
import AdminForum_HasilReportPosting from "./hasil_report/posting";
|
||||
import AdminForum_HasilReportKomentar from "./hasil_report/komentar";
|
||||
import AdminForum_Main from "./main/dashboard";
|
||||
import AdminForum_TablePosting from "./sub_menu/table_posting";
|
||||
import AdminForum_TableReportPosting from "./sub_menu/table_report_posting";
|
||||
import AdminForum_DetailPosting from "./detail/detail_posting";
|
||||
import AdminForum_HasilReportPosting from "./sub_detail/hasil_report_posting";
|
||||
import AdminForum_HasilReportKomentar from "./sub_detail/hasil_report_komentar";
|
||||
|
||||
export {
|
||||
AdminForum_Main,
|
||||
AdminForum_TablePublish,
|
||||
AdminForum_TableReportKomentar,
|
||||
AdminForum_TablePosting as AdminForum_TablePublish,
|
||||
AdminForum_TableReportPosting,
|
||||
AdminForum_LihatSemuaKomentar,
|
||||
AdminForum_DetailPosting as AdminForum_LihatSemuaKomentar,
|
||||
AdminForum_HasilReportPosting,
|
||||
AdminForum_HasilReportKomentar,
|
||||
};
|
||||
|
||||
@@ -23,7 +23,7 @@ export default function AdminForum_Main({
|
||||
countLaporanKomentar={countLaporanKomentar}
|
||||
/>
|
||||
</Stack>
|
||||
{/* <ComponentGlobalAdmin_LoadingPage /> */}
|
||||
{/* <ComponentAdminGlobal_LoadingPage /> */}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -46,13 +46,13 @@ function ForumMain({
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "Laporan Posting",
|
||||
name: "Report Posting",
|
||||
jumlah: countLaporanPosting,
|
||||
color: "orange",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "Laporan Komentar",
|
||||
name: "Report Komentar",
|
||||
jumlah: countLaporanKomentar,
|
||||
color: "red",
|
||||
},
|
||||
@@ -16,37 +16,48 @@ import {
|
||||
Center,
|
||||
Group,
|
||||
Modal,
|
||||
Pagination,
|
||||
Paper,
|
||||
ScrollArea,
|
||||
Spoiler,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
TextInput,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { IconMessageCircle, IconFlag3, IconTrash } from "@tabler/icons-react";
|
||||
import {
|
||||
IconMessageCircle,
|
||||
IconFlag3,
|
||||
IconTrash,
|
||||
IconSearch,
|
||||
} from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { adminForum_funDeletePostingById } from "../../fun/delete/fun_delete_posting_by_id";
|
||||
import { adminForum_funDeleteKomentarById } from "../../fun/delete/fun_delete_komentar_by_id";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { adminForum_funDeletePostingById } from "../fun/delete/fun_delete_posting_by_id";
|
||||
import { adminForum_funDeleteKomentarById } from "../fun/delete/fun_delete_komentar_by_id";
|
||||
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||
import ComponentAdminGlobal_IsEmptyData from "../../component_global/is_empty_data";
|
||||
import { adminForum_getListReportKomentarbyId } from "../fun/get/get_list_report_komentar_by_id";
|
||||
import ComponentAdminGlobal_BackButton from "../../component_global/back_button";
|
||||
|
||||
export default function AdminForum_HasilReportKomentar({
|
||||
komentarId,
|
||||
listReport,
|
||||
}: {
|
||||
komentarId: string;
|
||||
listReport: any[];
|
||||
listReport: any;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Forum: Hasil Report Komentar" />
|
||||
<Group position="apart">
|
||||
<ComponentAdminDonasi_TombolKembali />
|
||||
<ComponentAdminGlobal_BackButton />
|
||||
<ButtonDeleteKomentar komentarId={komentarId} />
|
||||
</Group>
|
||||
<HasilReportPosting listReport={listReport} />
|
||||
<HasilReportPosting listReport={listReport} komentarId={komentarId} />
|
||||
{/* <pre>{JSON.stringify(listReport, null, 2)}</pre> */}
|
||||
</Stack>
|
||||
</>
|
||||
@@ -56,13 +67,11 @@ export default function AdminForum_HasilReportKomentar({
|
||||
function ButtonDeleteKomentar({ komentarId }: { komentarId: string }) {
|
||||
const router = useRouter();
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [loadindDel, setLoadingDel] = useState(false);
|
||||
const [loadingDel2, setLoadingDel2] = useState(false);
|
||||
|
||||
async function onDelete() {
|
||||
await adminForum_funDeleteKomentarById(komentarId).then((res) => {
|
||||
if (res.status === 200) {
|
||||
setLoadingDel(false);
|
||||
setLoadingDel2(false);
|
||||
close();
|
||||
router.back();
|
||||
@@ -82,7 +91,6 @@ function ButtonDeleteKomentar({ komentarId }: { komentarId: string }) {
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
close();
|
||||
setLoadingDel(false);
|
||||
}}
|
||||
>
|
||||
Batal
|
||||
@@ -104,14 +112,12 @@ function ButtonDeleteKomentar({ komentarId }: { komentarId: string }) {
|
||||
</Modal>
|
||||
|
||||
<Button
|
||||
loading={loadindDel ? true : false}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
leftIcon={<IconTrash size={15} />}
|
||||
onClick={() => {
|
||||
open();
|
||||
setLoadingDel(true);
|
||||
}}
|
||||
>
|
||||
Hapus Komentar
|
||||
@@ -122,17 +128,32 @@ function ButtonDeleteKomentar({ komentarId }: { komentarId: string }) {
|
||||
|
||||
function HasilReportPosting({
|
||||
listReport,
|
||||
komentarId,
|
||||
}: {
|
||||
listReport: MODEL_FORUM_REPORT[];
|
||||
listReport: any;
|
||||
komentarId: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState(listReport);
|
||||
const [data, setData] = useState<MODEL_FORUM_REPORT[]>(listReport.data);
|
||||
const [nPage, setNPage] = useState(listReport.nPage);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isSearch, setSearch] = useState("");
|
||||
|
||||
async function onPageClick(p: any) {
|
||||
setActivePage(p);
|
||||
const loadData = await adminForum_getListReportKomentarbyId({
|
||||
komentarId: komentarId,
|
||||
page: p,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
}
|
||||
|
||||
const TableRows = data?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center>
|
||||
<Text w={200}>{e?.User?.Profile?.name}</Text>
|
||||
<Center w={200}>
|
||||
<Text>{e?.User?.Profile?.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
@@ -169,51 +190,72 @@ function HasilReportPosting({
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box>
|
||||
<Box bg={"red.1"} p={"xs"}>
|
||||
<Title order={6} c={"red"}>
|
||||
REPORT KOMENTAR
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
<Group
|
||||
position="apart"
|
||||
bg={"red.4"}
|
||||
p={"xs"}
|
||||
style={{ borderRadius: "6px" }}
|
||||
>
|
||||
<Title order={4} c={"white"}>
|
||||
Report Komentar
|
||||
</Title>
|
||||
</Box>
|
||||
<ScrollArea w={"100%"}>
|
||||
<Table
|
||||
withBorder
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"xl"}
|
||||
p={"md"}
|
||||
striped
|
||||
highlightOnHover
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center>Author</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Title</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Deskripsi</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Deskripsi Lainnya</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{TableRows}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
{/* <TextInput
|
||||
icon={<IconSearch size={20} />}
|
||||
radius={"xl"}
|
||||
placeholder="Cari postingan"
|
||||
onChange={(val) => {
|
||||
onSearch(val.currentTarget.value);
|
||||
}}
|
||||
/> */}
|
||||
</Group>
|
||||
|
||||
<Center>
|
||||
{_.isEmpty(TableRows) ? (
|
||||
<Center h={"50vh"}>
|
||||
<Title order={6}>Tidak Ada Data</Title>
|
||||
{_.isEmpty(data) ? (
|
||||
<ComponentAdminGlobal_IsEmptyData />
|
||||
) : (
|
||||
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"} offsetScrollbars>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={"100%"}
|
||||
h={"100%"}
|
||||
striped
|
||||
highlightOnHover
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Title</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Deskripsi</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Deskripsi Lainnya</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>{TableRows}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={activePage}
|
||||
total={nPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</Center>
|
||||
</Box>
|
||||
</Paper>
|
||||
)}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,21 +1,19 @@
|
||||
"use client";
|
||||
|
||||
import { RouterAdminForum } from "@/app/lib/router_admin/router_admin_forum";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component_global/header_tamplate";
|
||||
import ComponentAdminDonasi_TombolKembali from "@/app_modules/admin/donasi/component/tombol_kembali";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import {
|
||||
MODEL_FORUM_MASTER_REPORT,
|
||||
MODEL_FORUM_POSTING,
|
||||
MODEL_FORUM_REPORT,
|
||||
} from "@/app_modules/forum/model/interface";
|
||||
import {
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
Group,
|
||||
Modal,
|
||||
Pagination,
|
||||
Paper,
|
||||
ScrollArea,
|
||||
Spoiler,
|
||||
Stack,
|
||||
@@ -23,29 +21,37 @@ import {
|
||||
Text,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { IconMessageCircle, IconFlag3, IconTrash } from "@tabler/icons-react";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { IconTrash } from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { adminForum_funDeletePostingById } from "../../fun/delete/fun_delete_posting_by_id";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import ComponentAdminGlobal_BackButton from "../../component_global/back_button";
|
||||
import ComponentAdminGlobal_IsEmptyData from "../../component_global/is_empty_data";
|
||||
import { adminForum_funDeletePostingById } from "../fun/delete/fun_delete_posting_by_id";
|
||||
import { adminForum_getListReportPostingById } from "../fun/get/get_list_report_posting_by_id";
|
||||
import ComponentAdminForum_ViewOneDetailPosting from "../component/detail_one_posting";
|
||||
|
||||
export default function AdminForum_HasilReportPosting({
|
||||
postingId,
|
||||
dataPosting,
|
||||
listReport,
|
||||
}: {
|
||||
postingId: string;
|
||||
listReport: any[];
|
||||
dataPosting: MODEL_FORUM_POSTING;
|
||||
listReport: any;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Forum: Hasil Report Posting" />
|
||||
<Group position="apart">
|
||||
<ComponentAdminDonasi_TombolKembali />
|
||||
<ButtonDeletePosting postingId={postingId} />
|
||||
<ComponentAdminGlobal_BackButton />
|
||||
<ButtonDeletePosting postingId={dataPosting.id} />
|
||||
</Group>
|
||||
<HasilReportPosting listReport={listReport} />
|
||||
<ComponentAdminForum_ViewOneDetailPosting dataPosting={dataPosting} />
|
||||
<HasilReportPosting
|
||||
listReport={listReport}
|
||||
postingId={dataPosting.id}
|
||||
/>
|
||||
{/* <pre>{JSON.stringify(listReport, null, 2)}</pre> */}
|
||||
</Stack>
|
||||
</>
|
||||
@@ -125,21 +131,35 @@ function ButtonDeletePosting({ postingId }: { postingId: string }) {
|
||||
|
||||
function HasilReportPosting({
|
||||
listReport,
|
||||
postingId,
|
||||
}: {
|
||||
listReport: MODEL_FORUM_REPORT[];
|
||||
listReport: any;
|
||||
postingId: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState(listReport);
|
||||
const [data, setData] = useState<MODEL_FORUM_REPORT[]>(listReport.data);
|
||||
const [nPage, setNPage] = useState(listReport.nPage);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
|
||||
async function onPageClick(p: any) {
|
||||
setActivePage(p);
|
||||
const loadData = await adminForum_getListReportPostingById({
|
||||
postingId: postingId,
|
||||
page: p,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
}
|
||||
|
||||
const TableRows = data?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center>
|
||||
<Text w={200}>{e?.User?.Profile?.name}</Text>
|
||||
<Center w={200}>
|
||||
<Text>{e?.User?.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={100}>
|
||||
<Center w={200}>
|
||||
<Text>
|
||||
{e?.ForumMaster_KategoriReport?.title
|
||||
? e?.ForumMaster_KategoriReport?.title
|
||||
@@ -161,7 +181,7 @@ function HasilReportPosting({
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center>
|
||||
<Center w={500}>
|
||||
<Spoiler maxHeight={50} hideLabel="sembunyikan" showLabel="tampilkan">
|
||||
{e?.deskripsi ? <Text>{e?.deskripsi}</Text> : <Text>-</Text>}
|
||||
</Spoiler>
|
||||
@@ -172,51 +192,72 @@ function HasilReportPosting({
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box>
|
||||
<Box bg={"red.1"} p={"xs"}>
|
||||
<Title order={6} c={"red"}>
|
||||
REPORT POSTING
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
<Group
|
||||
position="apart"
|
||||
bg={"red.4"}
|
||||
p={"xs"}
|
||||
style={{ borderRadius: "6px" }}
|
||||
>
|
||||
<Title order={4} c={"white"}>
|
||||
Report Postingan
|
||||
</Title>
|
||||
</Box>
|
||||
<ScrollArea w={"100%"}>
|
||||
<Table
|
||||
withBorder
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"xl"}
|
||||
p={"md"}
|
||||
striped
|
||||
highlightOnHover
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center>Author</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Title</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Deskripsi</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Deskripsi Lainnya</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{TableRows}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
{/* <TextInput
|
||||
icon={<IconSearch size={20} />}
|
||||
radius={"xl"}
|
||||
placeholder="Cari postingan"
|
||||
onChange={(val) => {
|
||||
onSearch(val.currentTarget.value);
|
||||
}}
|
||||
/> */}
|
||||
</Group>
|
||||
|
||||
<Center>
|
||||
{_.isEmpty(TableRows) ? (
|
||||
<Center h={"50vh"}>
|
||||
<Title order={6}>Tidak Ada Data</Title>
|
||||
{_.isEmpty(data) ? (
|
||||
<ComponentAdminGlobal_IsEmptyData />
|
||||
) : (
|
||||
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"} offsetScrollbars>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={"100%"}
|
||||
h={"100%"}
|
||||
striped
|
||||
highlightOnHover
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Title</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Deskripsi</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Deskripsi Lainnya</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>{TableRows}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={activePage}
|
||||
total={nPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</Center>
|
||||
</Box>
|
||||
</Paper>
|
||||
)}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
357
src/app_modules/admin/forum/sub_menu/table_posting.tsx
Normal file
357
src/app_modules/admin/forum/sub_menu/table_posting.tsx
Normal file
@@ -0,0 +1,357 @@
|
||||
"use client";
|
||||
|
||||
import { RouterAdminForum } from "@/app/lib/router_admin/router_admin_forum";
|
||||
import { RouterForum } from "@/app/lib/router_hipmi/router_forum";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component_global/header_tamplate";
|
||||
import { MODEL_FORUM_POSTING } from "@/app_modules/forum/model/interface";
|
||||
import {
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
Group,
|
||||
Modal,
|
||||
Pagination,
|
||||
Paper,
|
||||
ScrollArea,
|
||||
Spoiler,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
TextInput,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { IconMessageCircle, IconSearch } from "@tabler/icons-react";
|
||||
import { IconFlag3 } from "@tabler/icons-react";
|
||||
import { IconEyeCheck, IconTrash } from "@tabler/icons-react";
|
||||
import _, { isEmpty } from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { adminForum_funDeletePostingById } from "../fun/delete/fun_delete_posting_by_id";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { adminForum_getListPosting } from "../fun/get/get_list_publish";
|
||||
import adminJob_getListPublish from "@/app_modules/admin/job/fun/get/get_list_publish";
|
||||
import ComponentAdminForum_ButtonDeletePosting from "../component/button_delete";
|
||||
import ComponentAdminGlobal_IsEmptyData from "../../component_global/is_empty_data";
|
||||
|
||||
export default function AdminForum_TablePosting({
|
||||
listPublish,
|
||||
}: {
|
||||
listPublish: any;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Forum" />
|
||||
<TablePublish listPublish={listPublish} />
|
||||
{/* <pre>{JSON.stringify(listPublish, null, 2)}</pre> */}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function TablePublish({ listPublish }: { listPublish: any }) {
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState<MODEL_FORUM_POSTING[]>(listPublish.data);
|
||||
const [nPage, setNPage] = useState(listPublish.nPage);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isSearch, setSearch] = useState("");
|
||||
|
||||
async function onSearch(s: string) {
|
||||
setSearch(s);
|
||||
setActivePage(1);
|
||||
const loadData = await adminForum_getListPosting({
|
||||
page: 1,
|
||||
search: s,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
}
|
||||
|
||||
async function onPageClick(p: any) {
|
||||
setActivePage(p);
|
||||
const loadData = await adminForum_getListPosting({
|
||||
search: isSearch,
|
||||
page: p,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
}
|
||||
|
||||
async function onLoadData() {
|
||||
const loadData = await adminForum_getListPosting({
|
||||
page: 1,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
}
|
||||
|
||||
const TableRows = data?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text lineClamp={1}>{e?.Author?.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={100}>
|
||||
<Badge
|
||||
color={
|
||||
(e?.ForumMaster_StatusPosting?.id as any) === 1 ? "green" : "red"
|
||||
}
|
||||
>
|
||||
{e?.ForumMaster_StatusPosting?.status}
|
||||
</Badge>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Box w={400}>
|
||||
<Spoiler
|
||||
// w={400}
|
||||
maxHeight={60}
|
||||
hideLabel="sembunyikan"
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
<div
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: e?.diskusi,
|
||||
}}
|
||||
/>
|
||||
</Spoiler>
|
||||
</Box>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Text>
|
||||
{new Intl.DateTimeFormat(["id-ID"], { dateStyle: "medium" }).format(
|
||||
e.createdAt
|
||||
)}
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Text fw={"bold"} fz={"lg"}>
|
||||
{e?.Forum_Komentar.length}
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Text
|
||||
c={e?.Forum_ReportPosting?.length >= 3 ? "red" : "black"}
|
||||
fw={"bold"}
|
||||
fz={"lg"}
|
||||
>
|
||||
{e?.Forum_ReportPosting.length}
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Stack align="center" spacing={"xs"}>
|
||||
<ButtonAction postingId={e?.id} />
|
||||
<ComponentAdminForum_ButtonDeletePosting
|
||||
postingId={e?.id}
|
||||
onSuccesDelete={(val) => {
|
||||
if (val) {
|
||||
onLoadData();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
<Group
|
||||
position="apart"
|
||||
bg={"green.4"}
|
||||
p={"xs"}
|
||||
style={{ borderRadius: "6px" }}
|
||||
>
|
||||
<Title order={4} c={"white"}>
|
||||
Posting
|
||||
</Title>
|
||||
<TextInput
|
||||
icon={<IconSearch size={20} />}
|
||||
radius={"xl"}
|
||||
placeholder="Cari postingan"
|
||||
onChange={(val) => {
|
||||
onSearch(val.currentTarget.value);
|
||||
}}
|
||||
/>
|
||||
</Group>
|
||||
{isEmpty(data) ? (
|
||||
<ComponentAdminGlobal_IsEmptyData />
|
||||
) : (
|
||||
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"} offsetScrollbars>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={"100%"}
|
||||
h={"100%"}
|
||||
striped
|
||||
highlightOnHover
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Status</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Text>Postingan</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tanggal Publish</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Komentar Aktif</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Total Report Posting</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{TableRows}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={activePage}
|
||||
total={nPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</Paper>
|
||||
)}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonAction({ postingId }: { postingId: string }) {
|
||||
const router = useRouter();
|
||||
const [loadingKomentar, setLoadingKomentar] = useState(false);
|
||||
const [loadingReport, setLoadingReport] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
fz={"xs"}
|
||||
loading={loadingKomentar ? true : false}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
w={170}
|
||||
leftIcon={<IconMessageCircle size={15} />}
|
||||
onClick={() => {
|
||||
setLoadingKomentar(true);
|
||||
router.push(RouterAdminForum.detail_posting + postingId);
|
||||
}}
|
||||
>
|
||||
<Text>Detail & Komentar</Text>
|
||||
</Button>
|
||||
<Button
|
||||
fz={"xs"}
|
||||
loading={loadingReport ? true : false}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
w={170}
|
||||
leftIcon={<IconFlag3 size={15} />}
|
||||
onClick={() => {
|
||||
setLoadingReport(true);
|
||||
router.push(RouterAdminForum.report_posting + postingId);
|
||||
}}
|
||||
>
|
||||
Hasil Report
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// function ButtonDeletePosting({ postingId }: { postingId: string }) {
|
||||
// const [opened, { open, close }] = useDisclosure(false);
|
||||
// const [loadingDel, setLoadingDel] = useState(false);
|
||||
// const [loadingDel2, setLoadingDel2] = useState(false);
|
||||
|
||||
// async function onDelete() {
|
||||
// await adminForum_funDeletePostingById(postingId).then((res) => {
|
||||
// if (res.status === 200) {
|
||||
// setLoadingDel2(false);
|
||||
// setLoadingDel(false);
|
||||
// close();
|
||||
// ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
// } else {
|
||||
// ComponentGlobal_NotifikasiGagal(res.message);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// return (
|
||||
// <>
|
||||
// <Modal
|
||||
// opened={opened}
|
||||
// onClose={close}
|
||||
// centered
|
||||
// withCloseButton={false}
|
||||
// closeOnClickOutside={false}
|
||||
// >
|
||||
// <Stack>
|
||||
// <Title order={5}>Anda yakin menghapus posting ini</Title>
|
||||
// <Group position="center">
|
||||
// <Button
|
||||
// radius={"xl"}
|
||||
// onClick={() => {
|
||||
// close();
|
||||
// setLoadingDel(false);
|
||||
// }}
|
||||
// >
|
||||
// Batal
|
||||
// </Button>
|
||||
// <Button
|
||||
// loaderPosition="center"
|
||||
// loading={loadingDel2 ? true : false}
|
||||
// radius={"xl"}
|
||||
// color="red"
|
||||
// onClick={() => {
|
||||
// onDelete();
|
||||
// setLoadingDel2(true);
|
||||
// }}
|
||||
// >
|
||||
// Hapus
|
||||
// </Button>
|
||||
// </Group>
|
||||
// </Stack>
|
||||
// </Modal>
|
||||
// <Button
|
||||
// fz={"xs"}
|
||||
// loaderPosition="center"
|
||||
// loading={loadingDel ? true : false}
|
||||
// radius={"xl"}
|
||||
// w={170}
|
||||
// color="red"
|
||||
// leftIcon={<IconTrash size={15} />}
|
||||
// onClick={() => {
|
||||
// // onDelete();
|
||||
// open();
|
||||
// setLoadingDel(true);
|
||||
// }}
|
||||
// >
|
||||
// Hapus Posting
|
||||
// </Button>
|
||||
// </>
|
||||
// );
|
||||
// }
|
||||
279
src/app_modules/admin/forum/sub_menu/table_report_posting.tsx
Normal file
279
src/app_modules/admin/forum/sub_menu/table_report_posting.tsx
Normal file
@@ -0,0 +1,279 @@
|
||||
"use client";
|
||||
|
||||
import { RouterAdminForum } from "@/app/lib/router_admin/router_admin_forum";
|
||||
import { RouterForum } from "@/app/lib/router_hipmi/router_forum";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component_global/header_tamplate";
|
||||
import {
|
||||
MODEL_FORUM_POSTING,
|
||||
MODEL_FORUM_REPORT,
|
||||
} from "@/app_modules/forum/model/interface";
|
||||
import {
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
Group,
|
||||
Modal,
|
||||
Pagination,
|
||||
Paper,
|
||||
ScrollArea,
|
||||
Spoiler,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
TextInput,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { IconMessageCircle, IconSearch } from "@tabler/icons-react";
|
||||
import { IconFlag3 } from "@tabler/icons-react";
|
||||
import { IconEyeCheck, IconTrash } from "@tabler/icons-react";
|
||||
import _, { isEmpty } from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { adminForum_funDeletePostingById } from "../fun/delete/fun_delete_posting_by_id";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { adminForum_getListPosting } from "../fun/get/get_list_publish";
|
||||
import adminJob_getListPublish from "@/app_modules/admin/job/fun/get/get_list_publish";
|
||||
import ComponentAdminForum_ButtonDeletePosting from "../component/button_delete";
|
||||
import adminForum_funGetAllReportPosting from "../fun/get/get_all_report_posting";
|
||||
import ComponentAdminGlobal_IsEmptyData from "../../component_global/is_empty_data";
|
||||
|
||||
export default function AdminForum_TableReportPosting({
|
||||
listData,
|
||||
}: {
|
||||
listData: any;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Forum" />
|
||||
<TableView listData={listData} />
|
||||
{/* <pre>{JSON.stringify(listPublish, null, 2)}</pre> */}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function TableView({ listData }: { listData: any }) {
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState<MODEL_FORUM_REPORT[]>(listData.data);
|
||||
const [nPage, setNPage] = useState(listData.nPage);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isSearch, setSearch] = useState("");
|
||||
|
||||
async function onSearch(s: string) {
|
||||
setSearch(s);
|
||||
setActivePage(1);
|
||||
const loadData = await adminForum_funGetAllReportPosting({
|
||||
page: 1,
|
||||
search: s,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
}
|
||||
|
||||
async function onPageClick(p: any) {
|
||||
setActivePage(p);
|
||||
const loadData = await adminForum_funGetAllReportPosting({
|
||||
search: isSearch,
|
||||
page: p,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
}
|
||||
|
||||
async function onLoadData() {
|
||||
const loadData = await adminForum_funGetAllReportPosting({
|
||||
page: 1,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
}
|
||||
|
||||
const TableRows = data?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text lineClamp={1}>{e?.User.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
{e?.forumMaster_KategoriReportId === null ? (
|
||||
<Text>Lainnya</Text>
|
||||
) : (
|
||||
<Text lineClamp={1}>{e?.ForumMaster_KategoriReport.title}</Text>
|
||||
)}
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text lineClamp={1}>{e?.Forum_Posting.Author.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Box w={400}>
|
||||
<Spoiler
|
||||
// w={400}
|
||||
maxHeight={60}
|
||||
hideLabel="sembunyikan"
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
<div
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: e?.Forum_Posting.diskusi,
|
||||
}}
|
||||
/>
|
||||
</Spoiler>
|
||||
</Box>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Badge
|
||||
color={
|
||||
(e?.Forum_Posting.ForumMaster_StatusPosting?.id as any) === 1
|
||||
? "green"
|
||||
: "red"
|
||||
}
|
||||
>
|
||||
{e?.Forum_Posting.ForumMaster_StatusPosting?.status}
|
||||
</Badge>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={150}>
|
||||
<Text>
|
||||
{new Intl.DateTimeFormat(["id-ID"], { dateStyle: "medium" }).format(
|
||||
e.createdAt
|
||||
)}
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Stack align="center" spacing={"xs"}>
|
||||
{/* <ButtonAction postingId={e?.id} /> */}
|
||||
<ButtonLihatReportLainnya postingId={e?.forum_PostingId} />
|
||||
<ComponentAdminForum_ButtonDeletePosting
|
||||
postingId={e?.forum_PostingId}
|
||||
onSuccesDelete={(val) => {
|
||||
if (val) {
|
||||
onLoadData();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
<Group
|
||||
position="apart"
|
||||
bg={"orange.4"}
|
||||
p={"xs"}
|
||||
style={{ borderRadius: "6px" }}
|
||||
>
|
||||
<Title order={4} c={"white"}>
|
||||
Report Posting
|
||||
</Title>
|
||||
<TextInput
|
||||
icon={<IconSearch size={20} />}
|
||||
radius={"xl"}
|
||||
placeholder="Cari postingan"
|
||||
onChange={(val) => {
|
||||
// console.log(val.currentTarget.value)
|
||||
onSearch(val.currentTarget.value);
|
||||
}}
|
||||
/>
|
||||
</Group>
|
||||
|
||||
{isEmpty(data) ? (
|
||||
<ComponentAdminGlobal_IsEmptyData />
|
||||
) : (
|
||||
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"} offsetScrollbars>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={"100%"}
|
||||
h={"100%"}
|
||||
striped
|
||||
highlightOnHover
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center>Pelapor</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Jenis Laporan</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Author</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Text>Postingan</Text>
|
||||
</th>
|
||||
<th>
|
||||
<Center w={200}>Status Posting</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tanggal Report</Center>
|
||||
</th>
|
||||
|
||||
<th>
|
||||
<Center>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{TableRows}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={activePage}
|
||||
total={nPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</Paper>
|
||||
)}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonLihatReportLainnya({ postingId }: { postingId: string }) {
|
||||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(false);
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
fz={"xs"}
|
||||
loading={loading ? true : false}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
w={170}
|
||||
leftIcon={<IconFlag3 size={15} />}
|
||||
onClick={() => {
|
||||
setLoading(true);
|
||||
router.push(RouterAdminForum.report_posting + postingId);
|
||||
}}
|
||||
>
|
||||
<Text>Lihat Report Lain</Text>
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user