- Tampilan admin untuk komentar
- Hapus komentar
- Hapus postingan
- Lihat report
- Search topik forum
## feat
### No issue
This commit is contained in:
2024-03-25 17:44:27 +08:00
parent de0790aade
commit 8af6c6265f
55 changed files with 2213 additions and 218 deletions

View File

@@ -640,26 +640,38 @@ model Job {
masterStatusId String? @default("2")
}
// ========================================= FORUM ========================================= //
model ForumMaster_StatusPosting {
id Int @id @default(autoincrement())
isActive Boolean @default(true)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
status String
Forum_Posting Forum_Posting[]
}
model Forum_Posting {
id String @id @default(cuid())
isActive Boolean @default(true)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
publishAt DateTime?
diskusi String @db.Text
Forum_Komentar Forum_Komentar[]
Forum_ReportPosting Forum_ReportPosting[]
Author User? @relation(fields: [authorId], references: [id])
authorId String?
id String @id @default(cuid())
isActive Boolean @default(true)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
publishAt DateTime?
diskusi String @db.Text
Forum_Komentar Forum_Komentar[]
Forum_ReportPosting Forum_ReportPosting[]
Author User? @relation(fields: [authorId], references: [id])
authorId String?
ForumMaster_StatusPosting ForumMaster_StatusPosting? @relation(fields: [forumMaster_StatusPostingId], references: [id])
forumMaster_StatusPostingId Int?
}
model Forum_Komentar {
id String @id @default(cuid())
isActive Boolean @default(true)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
komentar String @db.Text
id String @id @default(cuid())
isActive Boolean @default(true)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
komentar String @db.Text
Forum_Posting Forum_Posting? @relation(fields: [forum_PostingId], references: [id])
forum_PostingId String?
Forum_ReportKomentar Forum_ReportKomentar[]

View File

@@ -20,6 +20,7 @@ import event_tipe_acara from "../../../bin/seeder/event/master_tipe_acara.json";
import voting_status from "../../../bin/seeder/voting/master_status.json";
import master_status from "../../../bin/seeder/master_status.json";
import forum_kategori_report from "../../../bin/seeder/forum/master_report.json";
import forum_status_posting from "../../../bin/seeder/forum/master_status.json";
export async function GET(req: Request) {
const dev = new URL(req.url).searchParams.get("dev");
@@ -345,6 +346,20 @@ export async function GET(req: Request) {
});
}
for (let s of forum_status_posting) {
await prisma.forumMaster_StatusPosting.upsert({
where: {
id: s.id,
},
create: {
status: s.status,
},
update: {
status: s.status,
},
});
}
return NextResponse.json({ success: true });
}

View File

@@ -0,0 +1,9 @@
import ComponentAdminGlobal_LoadingPage from "@/app_modules/admin/component/loading_admin_page";
export default async function Page() {
return (
<>
<ComponentAdminGlobal_LoadingPage />
</>
);
}

View File

@@ -0,0 +1,9 @@
import ComponentAdminGlobal_LoadingPage from "@/app_modules/admin/component/loading_admin_page";
export default async function Page() {
return (
<>
<ComponentAdminGlobal_LoadingPage />
</>
);
}

View File

@@ -0,0 +1,12 @@
import { AdminForum_TablePublish } from "@/app_modules/admin/forum";
import { adminForum_getListPublish } from "@/app_modules/admin/forum/fun/get/get_list_publish";
export default async function Page() {
const listPublish = await adminForum_getListPublish();
return (
<>
<AdminForum_TablePublish listPublish={listPublish as any} />
</>
);
}

View File

@@ -0,0 +1,9 @@
import { AdminForum_TableReportKomentar } from "@/app_modules/admin/forum";
export default async function Page() {
return (
<>
<AdminForum_TableReportKomentar />
</>
);
}

View File

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

View File

@@ -0,0 +1,18 @@
import { AdminForum_LihatSemuaKomentar } from "@/app_modules/admin/forum";
import { adminForum_getListKomentarById } from "@/app_modules/admin/forum/fun/get/get_list_komentar_by_id";
import { adminForum_getOnePostingById } from "@/app_modules/admin/forum/fun/get/get_one_posting_by_id";
export default async function Page({ params }: { params: { id: string } }) {
let postingId = params.id;
const listKomentar = await adminForum_getListKomentarById(postingId);
const dataPosting = await adminForum_getOnePostingById(postingId);
return (
<>
<AdminForum_LihatSemuaKomentar
listKomentar={listKomentar as any}
dataPosting={dataPosting as any}
/>
</>
);
}

View File

@@ -0,0 +1,13 @@
import { AdminForum_HasilReportKomentar } from "@/app_modules/admin/forum"
import { adminForum_getListReportKomentarbyId } from "@/app_modules/admin/forum/fun/get/get_list_report_komentar_by_id";
export default async function Page({params}: {params: {id: string}}) {
let komentarId = params.id
const listReport = await adminForum_getListReportKomentarbyId(komentarId)
return (
<>
<AdminForum_HasilReportKomentar listReport={listReport} komentarId={komentarId} />
</>
);
}

View File

@@ -0,0 +1,16 @@
import { AdminForum_HasilReportPosting } from "@/app_modules/admin/forum";
import { adminForum_getListReportPostingById } from "@/app_modules/admin/forum/fun/get/get_list_report_posting_by_id";
export default async function Page({ params }: { params: { id: string } }) {
let postingId = params.id;
const listReport = await adminForum_getListReportPostingById(postingId);
return (
<>
<AdminForum_HasilReportPosting
postingId={postingId}
listReport={listReport}
/>
</>
);
}

View File

@@ -0,0 +1,9 @@
import ComponentAdminGlobal_LoadingPage from "@/app_modules/admin/component/loading_admin_page";
export default async function Page() {
return (
<>
<ComponentAdminGlobal_LoadingPage />
</>
);
}

View File

@@ -0,0 +1,12 @@
import { AdminForum_Main } from "@/app_modules/admin/forum";
export default async function Page() {
// await new Promise((a, b) => {
// setTimeout(a, 4000);
// });
return (
<>
<AdminForum_Main />
</>
);
}

View File

@@ -0,0 +1,9 @@
import ComponentAdminGlobal_LoadingPage from "@/app_modules/admin/component/loading_admin_page";
export default async function Page() {
return (
<>
<ComponentAdminGlobal_LoadingPage />
</>
);
}

View File

@@ -0,0 +1,9 @@
import ComponentAdminGlobal_LoadingPage from "@/app_modules/admin/component/loading_admin_page";
export default async function Page() {
return (
<>
<ComponentAdminGlobal_LoadingPage />
</>
);
}

View File

@@ -0,0 +1,9 @@
import ComponentAdminGlobal_LoadingPage from "@/app_modules/admin/component/loading_admin_page";
export default async function Page() {
return (
<>
<ComponentAdminGlobal_LoadingPage />
</>
);
}

View File

@@ -1,13 +1,18 @@
import { Forum_Komentar } from "@/app_modules/forum";
import { forum_getOnePostingById } from "@/app_modules/forum/fun/get/get_one_posting_by_id";
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
export default async function Page({ params }: { params: { id: string } }) {
let postingId = params.id;
const dataPosting = await forum_getOnePostingById(postingId);
const userLoginId = await User_getUserId()
return (
<>
<Forum_Komentar dataPosting={dataPosting as any} />
<Forum_Komentar
dataPosting={dataPosting as any}
userLoginId={userLoginId}
/>
</>
);
}

View File

@@ -3,12 +3,11 @@ import { forum_getListAllPosting } from "@/app_modules/forum/fun/get/get_list_al
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
export default async function Page() {
const listForum = await forum_getListAllPosting();
// console.log(listForum);
const userLoginId = await User_getUserId();
return (
<>
<Forum_Beranda listForum={listForum as any} />
<Forum_Beranda listForum={listForum as any} userLoginId={userLoginId} />
</>
);
}

View File

@@ -0,0 +1,13 @@
export const RouterAdminForum = {
main: "/dev/admin/forum/main",
publish: "/dev/admin/forum/child/publish",
report_komentar: "/dev/admin/forum/child/report-komentar",
report_posting: "/dev/admin/forum/child/report-posting",
//children
semua_komentar: "/dev/admin/forum/children/semua-komentar/",
// report
hasil_report_posting: "/dev/admin/forum/hasil-report/posting/",
hasil_report_komentar: "/dev/admin/forum/hasil-report/komentar/"
};

View File

@@ -0,0 +1,50 @@
"use client";
import {
Box,
Center,
Group,
LoadingOverlay,
Skeleton,
Text,
} from "@mantine/core";
export default function ComponentAdminGlobal_LoadingPage() {
const listhHuruf = [
{
huruf: "H",
},
{
huruf: "I",
},
{
huruf: "P",
},
{
huruf: "M",
},
{
huruf: "I",
},
];
const customLOader = (
<Center h={"100vh"}>
<Group>
{listhHuruf.map((e, i) => (
<Center key={i} h={"100%"}>
<Skeleton height={50} circle radius={"100%"} />
<Text sx={{ position: "absolute" }} c={"gray.4"} fw={"bold"}>
{e.huruf}
</Text>
</Center>
))}
</Group>
</Center>
);
return (
<>
<LoadingOverlay visible overlayBlur={1} loader={customLOader} />
</>
);
}

View File

@@ -0,0 +1,288 @@
"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/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>
</>
);
}

View File

@@ -0,0 +1,11 @@
"use client";
import { Stack } from "@mantine/core";
export default function AdminForum_TableReportKomentar() {
return (
<>
<Stack>ini rep komen</Stack>
</>
);
}

View File

@@ -0,0 +1,11 @@
"use client";
import { Stack } from "@mantine/core";
export default function AdminForum_TableReportPosting() {
return (
<>
<Stack>ini rep pos</Stack>
</>
);
}

View File

@@ -0,0 +1,291 @@
"use client";
import { RouterAdminForum } from "@/app/lib/router_admin/router_admin_forum";
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component/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>
</>
);
}

View File

@@ -0,0 +1,19 @@
"use server";
import prisma from "@/app/lib/prisma";
import { revalidatePath } from "next/cache";
export async function adminForum_funDeleteKomentarById(komentarId: string) {
const delTemporary = await prisma.forum_Komentar.update({
where: {
id: komentarId,
},
data: {
isActive: false,
},
});
if (!delTemporary) return { status: 400, message: "Gagal Dihapus" };
revalidatePath("/dev/admin/forum/children/semua-komentar");
return { status: 200, message: "Berhasil Dihapus" };
}

View File

@@ -0,0 +1,19 @@
"use server";
import prisma from "@/app/lib/prisma";
import { revalidatePath } from "next/cache";
export async function adminForum_funDeletePostingById(postingId: string) {
const delTemporary = await prisma.forum_Posting.update({
where: {
id: postingId,
},
data: {
isActive: false,
},
});
if (!delTemporary) return { status: 400, message: "Gagal Dihapus" };
revalidatePath("/dev/admin/forum/child/publish");
return { status: 200, message: "Berhasil Dihapus" };
}

View File

@@ -0,0 +1,36 @@
"use server";
import prisma from "@/app/lib/prisma";
export async function adminForum_getListKomentarById(postingId: string) {
const data = await prisma.forum_Komentar.findMany({
orderBy: {
createdAt: "desc",
},
where: {
forum_PostingId: postingId,
isActive: true,
},
select: {
id: true,
isActive: true,
komentar: true,
createdAt: true,
authorId: true,
Author: {
select: {
id: true,
Profile: {
select: {
name: true,
imagesId: true,
},
},
},
},
Forum_ReportKomentar: true
},
});
return data;
}

View File

@@ -0,0 +1,36 @@
"use server";
import prisma from "@/app/lib/prisma";
export async function adminForum_getListPublish() {
const data = await prisma.forum_Posting.findMany({
orderBy: {
createdAt: "desc",
},
where: {
isActive: true,
},
select: {
id: true,
diskusi: true,
isActive: true,
createdAt: true,
Author: {
select: {
id: true,
username: true,
Profile: true,
},
},
Forum_ReportPosting: true,
Forum_Komentar: {
where: {
isActive: true
}
},
ForumMaster_StatusPosting: true
},
});
return data;
}

View File

@@ -0,0 +1,30 @@
"use server";
import prisma from "@/app/lib/prisma";
export async function adminForum_getListReportKomentarbyId(komentarId: string) {
const data = await prisma.forum_ReportKomentar.findMany({
where: {
forum_KomentarId: komentarId,
},
select: {
id: true,
isActive: true,
createdAt: true,
deskripsi: true,
ForumMaster_KategoriReport: true,
User: {
select: {
Profile: {
select: {
id: true,
name: true,
},
},
},
},
},
});
return data;
}

View File

@@ -0,0 +1,34 @@
"use server";
import prisma from "@/app/lib/prisma";
export async function adminForum_getListReportPostingById(postingId: string) {
const data = await prisma.forum_ReportPosting.findMany({
where: {
forum_PostingId: postingId,
},
select: {
id: true,
deskripsi: true,
createdAt: true,
User: {
select: {
Profile: {
select: {
name: true,
},
},
},
},
ForumMaster_KategoriReport: {
select: {
id: true,
title: true,
deskripsi: true,
},
},
},
});
return data;
}

View File

@@ -0,0 +1,28 @@
"use server";
import prisma from "@/app/lib/prisma";
export async function adminForum_getOnePostingById(postingId: string) {
const data = await prisma.forum_Posting.findFirst({
where: {
id: postingId,
},
select: {
id: true,
diskusi: true,
Author: {
select: {
Profile: {
select: {
name: true
},
},
},
},
},
});
// console.log(data);
return data;
}

View File

@@ -0,0 +1,219 @@
"use client";
import { RouterAdminForum } from "@/app/lib/router_admin/router_admin_forum";
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component/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_REPORT,
} from "@/app_modules/forum/model/interface";
import {
Badge,
Box,
Button,
Center,
Group,
Modal,
ScrollArea,
Spoiler,
Stack,
Table,
Text,
Title,
} from "@mantine/core";
import { IconMessageCircle, IconFlag3, 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 { adminForum_funDeleteKomentarById } from "../../fun/delete/fun_delete_komentar_by_id";
import { useDisclosure } from "@mantine/hooks";
export default function AdminForum_HasilReportKomentar({
komentarId,
listReport,
}: {
komentarId: string;
listReport: any[];
}) {
return (
<>
<Stack>
<ComponentAdminGlobal_HeaderTamplate name="Forum: Hasil Report Komentar" />
<Group position="apart">
<ComponentAdminDonasi_TombolKembali />
<ButtonDeleteKomentar komentarId={komentarId} />
</Group>
<HasilReportPosting listReport={listReport} />
{/* <pre>{JSON.stringify(listReport, null, 2)}</pre> */}
</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);
close();
router.back();
ComponentGlobal_NotifikasiBerhasil(res.message);
} 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"}
color="red"
leftIcon={<IconTrash size={15} />}
onClick={() => {
open();
setLoadingDel(true);
}}
>
Hapus Komentar
</Button>
</>
);
}
function HasilReportPosting({
listReport,
}: {
listReport: MODEL_FORUM_REPORT[];
}) {
const router = useRouter();
const [data, setData] = useState(listReport);
const TableRows = data?.map((e, i) => (
<tr key={i}>
<td>
<Center>
<Text w={200}>{e?.User?.Profile?.name}</Text>
</Center>
</td>
<td>
<Center w={200}>
<Text>
{e?.ForumMaster_KategoriReport?.title
? e?.ForumMaster_KategoriReport?.title
: "-"}
</Text>
</Center>
</td>
<td>
<Center w={500}>
<Spoiler maxHeight={50} hideLabel="sembunyikan" showLabel="tampilkan">
{e?.ForumMaster_KategoriReport?.deskripsi ? (
<Text>{e?.ForumMaster_KategoriReport?.deskripsi}</Text>
) : (
<Text>-</Text>
)}
</Spoiler>
</Center>
</td>
<td>
<Center w={500}>
<Spoiler maxHeight={50} hideLabel="sembunyikan" showLabel="tampilkan">
{e?.deskripsi ? <Text>{e?.deskripsi}</Text> : <Text>-</Text>}
</Spoiler>
</Center>
</td>
</tr>
));
return (
<>
<Box>
<Box bg={"red.1"} p={"xs"}>
<Title order={6} c={"red"}>
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>
<Center>
{_.isEmpty(TableRows) ? (
<Center h={"50vh"}>
<Title order={6}>Tidak Ada Data</Title>
</Center>
) : (
""
)}
</Center>
</Box>
</>
);
}

View File

@@ -0,0 +1,222 @@
"use client";
import { RouterAdminForum } from "@/app/lib/router_admin/router_admin_forum";
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component/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_REPORT,
} from "@/app_modules/forum/model/interface";
import {
Badge,
Box,
Button,
Center,
Group,
Modal,
ScrollArea,
Spoiler,
Stack,
Table,
Text,
Title,
} from "@mantine/core";
import { IconMessageCircle, IconFlag3, 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";
export default function AdminForum_HasilReportPosting({
postingId,
listReport,
}: {
postingId: string;
listReport: any[];
}) {
return (
<>
<Stack>
<ComponentAdminGlobal_HeaderTamplate name="Forum: Hasil Report Posting" />
<Group position="apart">
<ComponentAdminDonasi_TombolKembali />
<ButtonDeletePosting postingId={postingId} />
</Group>
<HasilReportPosting listReport={listReport} />
{/* <pre>{JSON.stringify(listReport, null, 2)}</pre> */}
</Stack>
</>
);
}
function ButtonDeletePosting({ postingId }: { postingId: string }) {
const router = useRouter();
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();
router.back();
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
radius={"xl"}
color="red"
onClick={() => {
onDelete();
setLoadingDel2(true);
}}
>
Hapus
</Button>
</Group>
</Stack>
</Modal>
<Button
loaderPosition="center"
loading={loadingDel ? true : false}
radius={"xl"}
color="red"
leftIcon={<IconTrash size={15} />}
onClick={() => {
// onDelete();
open();
setLoadingDel(true);
}}
>
Hapus Posting
</Button>
</>
);
}
function HasilReportPosting({
listReport,
}: {
listReport: MODEL_FORUM_REPORT[];
}) {
const router = useRouter();
const [data, setData] = useState(listReport);
const TableRows = data?.map((e, i) => (
<tr key={i}>
<td>
<Center>
<Text w={200}>{e?.User?.Profile?.name}</Text>
</Center>
</td>
<td>
<Center w={100}>
<Text>
{e?.ForumMaster_KategoriReport?.title
? e?.ForumMaster_KategoriReport?.title
: "-"}
</Text>
</Center>
</td>
<td>
<Center w={500}>
<Spoiler maxHeight={50} hideLabel="sembunyikan" showLabel="tampilkan">
{e?.ForumMaster_KategoriReport?.deskripsi ? (
<Text>{e?.ForumMaster_KategoriReport?.deskripsi}</Text>
) : (
<Text>-</Text>
)}
</Spoiler>
</Center>
</td>
<td>
<Center>
<Spoiler maxHeight={50} hideLabel="sembunyikan" showLabel="tampilkan">
{e?.deskripsi ? <Text>{e?.deskripsi}</Text> : <Text>-</Text>}
</Spoiler>
</Center>
</td>
</tr>
));
return (
<>
<Box>
<Box bg={"red.1"} p={"xs"}>
<Title order={6} c={"red"}>
REPORT 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>Title</Center>
</th>
<th>
<Center>Deskripsi</Center>
</th>
<th>
<Center>Deskripsi Lainnya</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>
</>
);
}

View File

@@ -0,0 +1,17 @@
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";
export {
AdminForum_Main,
AdminForum_TablePublish,
AdminForum_TableReportKomentar,
AdminForum_TableReportPosting,
AdminForum_LihatSemuaKomentar,
AdminForum_HasilReportPosting,
AdminForum_HasilReportKomentar,
};

View File

@@ -0,0 +1,71 @@
"use client";
import { Group, Paper, SimpleGrid, Stack, Text, Title } from "@mantine/core";
import ComponentAdminGlobal_HeaderTamplate from "../../component/header_tamplate";
import ComponentAdminGlobal_LoadingPage from "../../component/loading_admin_page";
export default function AdminForum_Main() {
return (
<>
<Stack>
<ComponentAdminGlobal_HeaderTamplate name="Forum" />
<ForumMain />
</Stack>
{/* <ComponentGlobalAdmin_LoadingPage /> */}
</>
);
}
function ForumMain() {
const listBox = [
{
id: 1,
name: "Publish",
jumlah: 0,
color: "green",
},
{
id: 2,
name: "Laporan Posting",
jumlah: 0,
color: "orange",
},
{
id: 3,
name: "Laporan Komentar",
jumlah: 0,
color: "red",
},
];
return (
<>
<SimpleGrid
cols={4}
spacing="lg"
breakpoints={[
{ maxWidth: "62rem", cols: 4, spacing: "lg" },
{ maxWidth: "48rem", cols: 2, spacing: "sm" },
{ maxWidth: "36rem", cols: 1, spacing: "sm" },
]}
>
{listBox.map((e, i) => (
<Paper
key={i}
bg={`${"gray"}.2`}
shadow="md"
radius="md"
p="md"
// sx={{ borderColor: e.color, borderStyle: "solid" }}
>
<Group position="center">
<Stack align="center" spacing={0}>
<Text>{e.name}</Text>
<Title>{e.jumlah ? e.jumlah : 0}</Title>
</Stack>
</Group>
</Paper>
))}
</SimpleGrid>
</>
);
}

View File

@@ -11,6 +11,7 @@ import {
Footer,
Group,
Header,
Loader,
MediaQuery,
NavLink,
Navbar,
@@ -22,7 +23,13 @@ import {
import React, { useState } from "react";
import ComponentGlobal_HeaderTamplate from "../component_global/header_tamplate";
import { useDisclosure } from "@mantine/hooks";
import { IconCircleDot, IconCircleDotFilled, IconHome, IconLetterH, IconLogout } from "@tabler/icons-react";
import {
IconCircleDot,
IconCircleDotFilled,
IconHome,
IconLetterH,
IconLogout,
} from "@tabler/icons-react";
import {
RouterAdminAward,
RouterAdminDashboard,
@@ -51,6 +58,7 @@ export default function AdminLayout({
const router = useRouter();
const [active, setActive] = useAtom(gs_admin_hotMenu);
const [activeChild, setActiveChild] = useAtom(gs_admin_subMenu);
const [loading, setLoading] = useState(false);
const navbarItems = listAdminPage.map((e, i) => (
<Box key={e.id}>
@@ -61,9 +69,13 @@ export default function AdminLayout({
},
}}
fw={active === e.id ? "bold" : "normal"}
icon={e.icon}
icon={
// active === e.id ? loading ? <Loader size={10} /> : e.icon : e.icon
e.icon
}
label={<Text size={"sm"}>{e.name}</Text>}
onClick={() => {
setLoading(true);
setActive(e.id);
setActiveChild(null);
e.path === "" ? router.push(e.child[0].path) : router.push(e.path);
@@ -84,7 +96,13 @@ export default function AdminLayout({
}}
fw={activeChild === v.id ? "bold" : "normal"}
label={<Text>{v.name}</Text>}
icon={activeChild === v.id ? <IconCircleDotFilled size={10}/> : <IconCircleDot size={10}/> }
icon={
activeChild === v.id ? (
<IconCircleDotFilled size={10} />
) : (
<IconCircleDot size={10} />
)
}
onClick={() => {
setActive(e.id);
setActiveChild(v.id);
@@ -105,7 +123,6 @@ export default function AdminLayout({
padding="md"
navbarOffsetBreakpoint="md"
asideOffsetBreakpoint="sm"
navbar={
<MediaQuery smallerThan={"md"} styles={{ display: "none" }}>
<Navbar

View File

@@ -1,4 +1,5 @@
import { RouterAdminEvent } from "@/app/lib/router_admin/router_admin_event";
import { RouterAdminForum } from "@/app/lib/router_admin/router_admin_forum";
import { RouterAdminJob } from "@/app/lib/router_admin/router_admin_job";
import { RouterAdminVote } from "@/app/lib/router_admin/router_admin_vote";
import {
@@ -6,7 +7,7 @@ import {
RouterAdminDonasi,
RouterAdminInvestasi,
} from "@/app/lib/router_hipmi/router_admin";
import { IconBriefcase } from "@tabler/icons-react";
import { IconBriefcase, IconMessages } from "@tabler/icons-react";
import {
IconHeartHandshake,
IconHome,
@@ -142,4 +143,32 @@ export const listAdminPage = [
},
],
},
{
id: 7,
name: "Forum",
path: "",
icon: <IconMessages />,
child: [
{
id: 71,
name: "Dashboard",
path: RouterAdminForum.main,
},
{
id: 72,
name: "Table Posting",
path: RouterAdminForum.publish,
},
{
id: 73,
name: "Laporan Posting",
path: RouterAdminForum.report_posting,
},
{
id: 74,
name: "Laporan Komentar",
path: RouterAdminForum.report_komentar,
},
],
},
];

View File

@@ -10,6 +10,7 @@ import {
Group,
ThemeIcon,
ActionIcon,
Badge,
} from "@mantine/core";
import { useRouter } from "next/navigation";
import moment from "moment";
@@ -31,14 +32,18 @@ export default function ComponentForum_DetailOnHeaderAuthorName({
authorName,
username,
isPembatas,
userLoginId,
statusId,
}: {
authorId?: string
authorId?: string;
postingId?: string;
imagesId?: string;
authorName?: string;
username?: string;
tglPublish?: Date;
isPembatas?: boolean;
statusId: string;
userLoginId: string;
}) {
const router = useRouter();
@@ -73,40 +78,21 @@ export default function ComponentForum_DetailOnHeaderAuthorName({
<Text lineClamp={1} fz={"sm"} fw={"bold"}>
{authorName ? authorName : "Nama author "}
</Text>
<Text lineClamp={1} fz={"xs"} c={"gray"}>
{username ? `@${username}` : "@username "}
</Text>
<Badge
w={70}
variant="light"
color={(statusId as any) === 1 ? "green" : "red"}
>
<Text fz={10}>{(statusId as any) === 1 ? "Open" : "Close"}</Text>
</Badge>
</Stack>
{/* <Stack justify="center" h={"100%"}>
<Grid>
<Grid.Col span={"auto"}>
<Text lineClamp={1} fz={"sm"} fw={"bold"}>
{authorName ? authorName : "Nama author "}
</Text>
</Grid.Col>
<Grid.Col span={"auto"}>
<Text lineClamp={1} fz={"sm"} c={"gray"}>
{username ? username : "@username "}
</Text>
</Grid.Col>
<Grid.Col span={"auto"}>
<Group spacing={3}>
<IconCircle size={5} color="gray" />
<Text c={"gray"} fz={"sm"}>
{skrng.toLocaleDateString(["id-ID"], {
dateStyle: "medium",
})}
</Text>
</Group>
</Grid.Col>
</Grid>
</Stack> */}
</Grid.Col>
<Grid.Col span={"content"}>
<ComponentForum_DetailMoreButton
postingId={postingId}
authorId={authorId}
userLoginId={userLoginId}
statusId={statusId}
/>
</Grid.Col>
</Grid>

View File

@@ -1,7 +1,16 @@
"use client";
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import { Stack, Grid, Avatar, Divider, Text, Group } from "@mantine/core";
import {
Stack,
Grid,
Avatar,
Divider,
Text,
Group,
Badge,
Loader,
} from "@mantine/core";
import { useRouter } from "next/navigation";
import moment from "moment";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan";
@@ -19,6 +28,7 @@ import { IoIosMore } from "react-icons/io";
import { useDisclosure } from "@mantine/hooks";
import { useState } from "react";
import ComponentForum_PostingButtonMore from "../more_button/posting_button_more";
import ComponentGlobal_V2_LoadingPage from "@/app_modules/component_global/loading_page_v2";
export default function ComponentForum_PostingAuthorNameOnHeader({
authorId,
@@ -28,6 +38,8 @@ export default function ComponentForum_PostingAuthorNameOnHeader({
tglPublish,
isPembatas,
isMoreButton,
statusId,
userLoginId,
}: {
authorId?: string;
postingId?: string;
@@ -36,8 +48,12 @@ export default function ComponentForum_PostingAuthorNameOnHeader({
tglPublish?: Date;
isPembatas?: boolean;
isMoreButton?: boolean;
statusId?: string;
userLoginId: string;
}) {
const router = useRouter();
const [loading, setLoading] = useState(false);
return (
<>
<Stack spacing={"xs"}>
@@ -46,43 +62,52 @@ export default function ComponentForum_PostingAuthorNameOnHeader({
span={"content"}
onClick={() => {
if (authorId) {
setLoading(true);
router.push(RouterForum.forumku + authorId);
} else {
ComponentGlobal_NotifikasiPeringatan("Id tidak ditemukan");
}
}}
>
<Avatar
size={30}
sx={{ borderStyle: "solid", borderWidth: "0.5px" }}
radius={"xl"}
bg={"gray.1"}
src={
imagesId
? RouterProfile.api_foto_profile + imagesId
: "/aset/global/avatar.png"
}
/>
{loading ? (
<Loader color="gray" variant="dots" />
) : (
<Avatar
size={40}
sx={{ borderStyle: "solid", borderWidth: "0.5px" }}
radius={"xl"}
bg={"gray.1"}
src={
imagesId
? RouterProfile.api_foto_profile + imagesId
: "/aset/global/avatar.png"
}
/>
)}
</Grid.Col>
<Grid.Col span={"auto"}>
<Stack justify="center" h={"100%"}>
<Stack justify="center" h={"100%"} spacing={0}>
<Grid>
<Grid.Col span={"auto"}>
<Text lineClamp={1} fz={"sm"} fw={"bold"}>
{authorName
? authorName
: "Nama author coba di berikan panjang "}
{authorName ? authorName : "Nama author "}
</Text>
</Grid.Col>
{/* <Grid.Col span={"auto"}>
<Text lineClamp={1} fz={"sm"} c={"gray"}>
{username ? username : "@username "}
</Text>
</Grid.Col> */}
<Grid.Col span={"content"}></Grid.Col>
</Grid>
<Badge
w={70}
variant="light"
color={(statusId as any) === 1 ? "green" : "red"}
>
<Text fz={10}>
{(statusId as any) === 1 ? "Open" : "Close"}
</Text>
</Badge>
</Stack>
</Grid.Col>
<Grid.Col span={"content"}>
<Group position="center" spacing={"xs"}>
<Group spacing={3}>
@@ -108,6 +133,8 @@ export default function ComponentForum_PostingAuthorNameOnHeader({
<ComponentForum_PostingButtonMore
authorId={authorId}
postingId={postingId as any}
statusId={statusId}
userLoginId={userLoginId}
/>
</Group>
) : (

View File

@@ -2,7 +2,7 @@
import { RouterForum } from "@/app/lib/router_hipmi/router_forum";
import { Stack, Card, Group, ActionIcon, Divider, Text } from "@mantine/core";
import { IconMessageCircle } from "@tabler/icons-react";
import { IconMessageCircle, IconMessageCircleOff } from "@tabler/icons-react";
import ComponentForum_PostingAuthorNameOnHeader from "./header/posting_author_header_name";
import { MODEL_FORUM_POSTING } from "../model/interface";
@@ -12,23 +12,28 @@ import { useRouter } from "next/navigation";
import { useAtom } from "jotai";
import { gs_forum_total_komentar } from "../global_state";
import { forum_countOneTotalKomentarById } from "../fun/count/count_one_total_komentar_by_id";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan";
import { IconMessageCircleX } from "@tabler/icons-react";
export default function ComponentForum_MainCardView({
data,
setLoadingKomen,
setLoadingDetail,
userLoginId,
}: {
data: MODEL_FORUM_POSTING[];
setLoadingKomen: any;
setLoadingDetail: any;
userLoginId: any
}) {
const router = useRouter();
return (
<>
<Stack>
<Stack spacing={"xl"}>
{data.map((e, i) => (
<Card key={i}>
<Card.Section>
{/* <pre>{JSON.stringify( typeof e.ForumMaster_StatusPosting.id)}</pre> */}
<ComponentForum_PostingAuthorNameOnHeader
authorName={e?.Author?.Profile?.name}
imagesId={e?.Author?.Profile?.imagesId}
@@ -36,22 +41,22 @@ export default function ComponentForum_MainCardView({
isMoreButton={true}
authorId={e?.Author?.id}
postingId={e?.id}
statusId={e?.ForumMaster_StatusPosting?.id}
userLoginId={userLoginId}
/>
</Card.Section>
<Card.Section
sx={{ zIndex: 0 }}
p={"sm"}
p={"lg"}
onClick={() => {
// console.log("halaman forum");
setLoadingDetail(true);
router.push(RouterForum.main_detail + e.id);
}}
>
<Stack spacing={"xs"}>
<Text fz={"sm"} lineClamp={4}>
<div dangerouslySetInnerHTML={{ __html: e.diskusi }} />
</Text>
</Stack>
<Text fz={"sm"} lineClamp={4}>
<div dangerouslySetInnerHTML={{ __html: e.diskusi }} />
</Text>
</Card.Section>
<Card.Section>
<Stack>
@@ -61,11 +66,17 @@ export default function ComponentForum_MainCardView({
variant="transparent"
sx={{ zIndex: 1 }}
onClick={() => {
setLoadingKomen(true);
router.push(RouterForum.komentar + e.id);
(e?.ForumMaster_StatusPosting.id as any) === 1
? (router.push(RouterForum.komentar + e?.id),
setLoadingKomen(true))
: router.push(RouterForum.main_detail + e?.id);
}}
>
<IconMessageCircle color="gray" size={25} />
{(e?.ForumMaster_StatusPosting?.id as any) === 1 ? (
<IconMessageCircle color="gray" size={25} />
) : (
<IconMessageCircleX color="gray" size={25} />
)}
</ActionIcon>
{/* <TotalKomentar postingId={e?.id} /> */}
@@ -81,18 +92,3 @@ export default function ComponentForum_MainCardView({
</>
);
}
function TotalKomentar({ postingId }: { postingId: string }) {
const [value, setValue] = useState(0)
useShallowEffect(() => {
forum_countOneTotalKomentarById(postingId).then((res) => {
setValue(res);
});
}, [postingId]);
return (
<>
<Text c={"gray"}>{value}</Text>
</>
);
}

View File

@@ -17,7 +17,13 @@ import {
Loader,
} from "@mantine/core";
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
import { IconTrash, IconEdit, IconFlag3, IconDots } from "@tabler/icons-react";
import {
IconTrash,
IconEdit,
IconFlag3,
IconDots,
IconSquareRoundedX,
} from "@tabler/icons-react";
import { useRouter } from "next/navigation";
import { useState } from "react";
@@ -29,18 +35,24 @@ import ComponentForum_LoadingDrawer from "../loading_drawer";
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
import { forum_funDeletePostingById } from "../../fun/delete/fun_delete_posting_by_id";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
import { IconSquareCheck } from "@tabler/icons-react";
import { forum_funEditStatusPostingById } from "../../fun/edit/fun_edit_status_posting_by_id";
export default function ComponentForum_DetailMoreButton({
authorId,
postingId,
statusId,
userLoginId,
}: {
authorId: any;
postingId?: any;
statusId: any;
userLoginId: any;
}) {
const router = useRouter();
const [opened, { open, close }] = useDisclosure(false);
const [openDel, setOpenDel] = useState(false);
const [userLoginId, setUserLoginId] = useState("");
const [openStatusClose, setOpenStatusClose] = useState(false);
// loading
const [loadingEdit, setLoadingEdit] = useState(false);
@@ -48,15 +60,6 @@ export default function ComponentForum_DetailMoreButton({
// if (loadingEdit) return <ComponentGlobal_V2_LoadingPage />;
useShallowEffect(() => {
getUserLoginId();
}, []);
async function getUserLoginId() {
const getUserLoginId = await User_getUserId();
setUserLoginId(getUserLoginId);
}
return (
<>
<Drawer
@@ -73,6 +76,28 @@ export default function ComponentForum_DetailMoreButton({
""
) : (
<Stack>
<Grid
onClick={() => {
close();
setOpenStatusClose(true);
}}
>
<Grid.Col span={"content"}>
{statusId === 1 ? (
<IconSquareRoundedX color="red" />
) : (
<IconSquareCheck />
)}
</Grid.Col>
<Grid.Col span={"auto"}>
{statusId === 1 ? (
<Text c={"red"}>Tutup forum</Text>
) : (
<Text>Buka forum</Text>
)}
</Grid.Col>
</Grid>
<Grid
onClick={() => {
close();
@@ -146,6 +171,19 @@ export default function ComponentForum_DetailMoreButton({
<ButtonDelete postingId={postingId} setOpenDel={setOpenDel} />
</Modal>
<Modal
opened={openStatusClose}
onClose={() => setOpenStatusClose(false)}
centered
withCloseButton={false}
>
<ButtonStatus
postingId={postingId}
setOpenStatus={setOpenStatusClose}
statusId={statusId}
/>
</Modal>
<ActionIcon variant="transparent" onClick={() => open()}>
<IconDots size={20} />
</ActionIcon>
@@ -201,3 +239,84 @@ function ButtonDelete({
</>
);
}
function ButtonStatus({
postingId,
setOpenStatus,
statusId,
}: {
postingId?: string;
setOpenStatus: any;
statusId?: any;
}) {
const [loading, setLoading] = useState(false);
async function onTutupForum() {
setOpenStatus(false);
await forum_funEditStatusPostingById(postingId as any, 2).then((res) => {
if (res.status === 200) {
ComponentGlobal_NotifikasiBerhasil(`Forum Ditutup`, 2000);
setLoading(true);
} else {
ComponentGlobal_NotifikasiGagal(res.message);
}
});
}
async function onBukaForum() {
setOpenStatus(false);
await forum_funEditStatusPostingById(postingId as any, 1).then((res) => {
if (res.status === 200) {
ComponentGlobal_NotifikasiBerhasil(`Forum Dibuka`, 2000);
setLoading(true);
} else {
ComponentGlobal_NotifikasiGagal(res.message);
}
});
}
return (
<>
<Stack>
{statusId === 1 ? (
<Title order={6}>Yakin menutup forum ini ?</Title>
) : (
<Title order={6}>Yakin membuka forum ini ?</Title>
)}
<Group position="center">
<Button radius={"xl"} onClick={() => setOpenStatus(false)}>
Batal
</Button>
{statusId === 1 ? (
<Button
loaderPosition="center"
loading={loading ? true : false}
color="red"
radius={"xl"}
onClick={() => {
onTutupForum();
}}
>
Hapus
</Button>
) : (
<Button
loaderPosition="center"
loading={loading ? true : false}
color="green"
radius={"xl"}
onClick={() => {
onBukaForum();
}}
>
Buka
</Button>
)}
</Group>
</Stack>
</>
);
}

View File

@@ -17,7 +17,14 @@ import {
Loader,
} from "@mantine/core";
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
import { IconTrash, IconEdit, IconFlag3, IconDots } from "@tabler/icons-react";
import {
IconTrash,
IconEdit,
IconFlag3,
IconDots,
IconSquareRoundedX,
IconSquareCheck,
} from "@tabler/icons-react";
import { useRouter } from "next/navigation";
import { useState } from "react";
@@ -29,18 +36,25 @@ import ComponentForum_LoadingDrawer from "../loading_drawer";
import { User_getUserId } from "@/app_modules/fun_global/get_user_token";
import { forum_funDeletePostingById } from "../../fun/delete/fun_delete_posting_by_id";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
import { forum_funEditStatusPostingById } from "../../fun/edit/fun_edit_status_posting_by_id";
export default function ComponentForum_PostingButtonMore({
authorId,
postingId,
statusId,
userLoginId,
}: {
authorId: any;
postingId?: any;
statusId?: any;
userLoginId: any;
}) {
const router = useRouter();
// modal & drawer
const [opened, { open, close }] = useDisclosure(false);
const [openDel, setOpenDel] = useState(false);
const [userLoginId, setUserLoginId] = useState("");
const [openStatusClose, setOpenStatusClose] = useState(false);
// loading
const [loadingEdit, setLoadingEdit] = useState(false);
@@ -48,15 +62,6 @@ export default function ComponentForum_PostingButtonMore({
// if (loadingEdit) return <ComponentGlobal_V2_LoadingPage />;
useShallowEffect(() => {
getUserLoginId();
}, []);
async function getUserLoginId() {
const getUserLoginId = await User_getUserId();
setUserLoginId(getUserLoginId);
}
return (
<>
<Drawer
@@ -73,6 +78,28 @@ export default function ComponentForum_PostingButtonMore({
""
) : (
<Stack>
<Grid
onClick={() => {
close();
setOpenStatusClose(true);
}}
>
<Grid.Col span={"content"}>
{statusId === 1 ? (
<IconSquareRoundedX color="red" />
) : (
<IconSquareCheck />
)}
</Grid.Col>
<Grid.Col span={"auto"}>
{statusId === 1 ? (
<Text c={"red"}>Tutup forum</Text>
) : (
<Text>Buka forum</Text>
)}
</Grid.Col>
</Grid>
<Grid
onClick={() => {
close();
@@ -146,6 +173,19 @@ export default function ComponentForum_PostingButtonMore({
<ButtonDelete postingId={postingId} setOpenDel={setOpenDel} />
</Modal>
<Modal
opened={openStatusClose}
onClose={() => setOpenStatusClose(false)}
centered
withCloseButton={false}
>
<ButtonStatus
postingId={postingId}
setOpenStatus={setOpenStatusClose}
statusId={statusId}
/>
</Modal>
<ActionIcon variant="transparent" onClick={() => open()}>
<IconDots size={20} />
</ActionIcon>
@@ -160,18 +200,18 @@ function ButtonDelete({
postingId?: string;
setOpenDel: any;
}) {
const [loading, setLoading] = useState(false);
const [loading, setLoading] = useState(false);
async function onDelete() {
setOpenDel(false);
await forum_funDeletePostingById(postingId as any).then((res) => {
if (res.status === 200) {
ComponentGlobal_NotifikasiBerhasil(`Postingan Terhapus`, 2000);
setLoading(true)
} else {
ComponentGlobal_NotifikasiGagal(res.message);
}
});
await forum_funDeletePostingById(postingId as any).then((res) => {
if (res.status === 200) {
ComponentGlobal_NotifikasiBerhasil(`Postingan Terhapus`, 2000);
setLoading(true);
} else {
ComponentGlobal_NotifikasiGagal(res.message);
}
});
}
return (
<>
@@ -197,3 +237,84 @@ function ButtonDelete({
</>
);
}
function ButtonStatus({
postingId,
setOpenStatus,
statusId,
}: {
postingId?: string;
setOpenStatus: any;
statusId?: any;
}) {
const [loading, setLoading] = useState(false);
async function onTutupForum() {
setOpenStatus(false);
await forum_funEditStatusPostingById(postingId as any, 2).then((res) => {
if (res.status === 200) {
ComponentGlobal_NotifikasiBerhasil(`Forum Ditutup`, 2000);
setLoading(true);
} else {
ComponentGlobal_NotifikasiGagal(res.message);
}
});
}
async function onBukaForum() {
setOpenStatus(false);
await forum_funEditStatusPostingById(postingId as any, 1).then((res) => {
if (res.status === 200) {
ComponentGlobal_NotifikasiBerhasil(`Forum Dibuka`, 2000);
setLoading(true);
} else {
ComponentGlobal_NotifikasiGagal(res.message);
}
});
}
return (
<>
<Stack>
{statusId === 1 ? (
<Title order={6}>Yakin menutup forum ini ?</Title>
) : (
<Title order={6}>Yakin membuka forum ini ?</Title>
)}
<Group position="center">
<Button radius={"xl"} onClick={() => setOpenStatus(false)}>
Batal
</Button>
{statusId === 1 ? (
<Button
loaderPosition="center"
loading={loading ? true : false}
color="red"
radius={"xl"}
onClick={() => {
onTutupForum();
}}
>
Hapus
</Button>
) : (
<Button
loaderPosition="center"
loading={loading ? true : false}
color="green"
radius={"xl"}
onClick={() => {
onBukaForum();
}}
>
Buka
</Button>
)}
</Group>
</Stack>
</>
);
}

View File

@@ -44,15 +44,26 @@ export default function Forum_Detail({
dataPosting: MODEL_FORUM_POSTING;
listKomentar: MODEL_FORUM_KOMENTAR[];
totalKomentar: number;
userLoginId: string
userLoginId: string;
}) {
const [komentar, setKomentar] = useState(listKomentar);
return (
<>
<Stack px={"xs"}>
<ForumView dataPosting={dataPosting} totalKomentar={totalKomentar} />
<CreateKomentar postingId={dataPosting?.id} setKomentar={setKomentar} />
<ForumView
dataPosting={dataPosting}
totalKomentar={totalKomentar}
userLoginId={userLoginId}
/>
{(dataPosting?.ForumMaster_StatusPosting?.id as any) === 1 ? (
<CreateKomentar
postingId={dataPosting?.id}
setKomentar={setKomentar}
/>
) : (
""
)}
<KomentarView
listKomentar={komentar}
setKomentar={setKomentar}
@@ -67,15 +78,17 @@ export default function Forum_Detail({
function ForumView({
dataPosting,
totalKomentar,
userLoginId,
}: {
dataPosting: MODEL_FORUM_POSTING;
totalKomentar: number
totalKomentar: number;
userLoginId: string;
}) {
return (
<>
<Card style={{ position: "relative", width: "100%" }}>
<Card.Section>
{/* <pre>{JSON.stringify(dataPosting, null, 2)}</pre> */}
<ComponentForum_DetailOnHeaderAuthorName
authorId={dataPosting?.Author?.id}
authorName={dataPosting?.Author?.Profile?.name}
@@ -83,6 +96,8 @@ function ForumView({
imagesId={dataPosting?.Author?.Profile?.imagesId}
postingId={dataPosting?.id}
tglPublish={dataPosting?.createdAt}
userLoginId={userLoginId}
statusId={dataPosting?.ForumMaster_StatusPosting?.id}
/>
</Card.Section>
<Card.Section sx={{ zIndex: 0 }} py={"sm"}>
@@ -202,7 +217,7 @@ function KomentarView({
listKomentar: MODEL_FORUM_KOMENTAR[];
setKomentar: any;
postingId: string;
userLoginId: string
userLoginId: string;
}) {
return (
<>

View File

@@ -30,6 +30,7 @@ import ComponentGlobal_V2_LoadingPage from "@/app_modules/component_global/loadi
import { MODEL_FORUM_POSTING } from "../model/interface";
import ComponentForum_MainCardView from "../component/main_card_view";
import { useWindowScroll } from "@mantine/hooks";
import _ from "lodash";
export default function Forum_Forumku({
auhtorSelectedData,
@@ -77,7 +78,15 @@ export default function Forum_Forumku({
auhtorSelectedData={auhtorSelectedData}
totalPosting={totalPosting}
/>
<ForumPosting dataPosting={dataPosting} />
{_.isEmpty(dataPosting) ? (
<Center>
<Text fw={"bold"} fz={"xs"} c={"gray"}>
Belum ada posting
</Text>
</Center>
) : (
<ForumPosting dataPosting={dataPosting} userLoginId={userLoginId} />
)}
</Stack>
</>
);
@@ -160,7 +169,13 @@ function ForumProfile({
);
}
function ForumPosting({ dataPosting }: { dataPosting: MODEL_FORUM_POSTING[] }) {
function ForumPosting({
dataPosting,
userLoginId,
}: {
dataPosting: MODEL_FORUM_POSTING[];
userLoginId: any;
}) {
const router = useRouter();
const [loadingDetail, setLoadingDetail] = useState(false);
@@ -174,6 +189,7 @@ function ForumPosting({ dataPosting }: { dataPosting: MODEL_FORUM_POSTING[] }) {
data={dataPosting}
setLoadingKomen={setLoadingKomen}
setLoadingDetail={setLoadingDetail}
userLoginId={userLoginId}
/>
{/* <Stack>

View File

@@ -11,6 +11,7 @@ export async function forum_funCreate(value: string) {
data: {
diskusi: value,
authorId: AuthorId,
forumMaster_StatusPostingId: 1
},
});

View File

@@ -0,0 +1,24 @@
"use server";
import prisma from "@/app/lib/prisma";
import { revalidatePath } from "next/cache";
export async function forum_funEditStatusPostingById(
postingId: string,
statusId: number
) {
const updt = await prisma.forum_Posting.update({
where: {
id: postingId,
},
data: {
forumMaster_StatusPostingId: statusId,
},
});
if (!updt) return { status: 400, message: "Gagal update posting" };
revalidatePath("/dev/forum/main");
revalidatePath("/dev/forum/detail");
revalidatePath("/dev/forum/forumku");
return { status: 200, message: "Berhasil update posting" };
}

View File

@@ -7,11 +7,17 @@ import { forum_countTotalKomenById } from "../count/count_total_komentar_by_id";
export async function forum_getListAllPosting() {
const get = await prisma.forum_Posting.findMany({
orderBy: {
createdAt: "desc",
},
orderBy: [
// {
// forumMaster_StatusPostingId: "asc",
// },
{
createdAt: "desc",
},
],
where: {
isActive: true,
// forumMaster_StatusPostingId: 1
},
select: {
id: true,
@@ -30,6 +36,7 @@ export async function forum_getListAllPosting() {
isActive: true,
},
},
ForumMaster_StatusPosting: true,
// _count: {
// select: {
// Forum_Komentar: true,
@@ -38,17 +45,10 @@ export async function forum_getListAllPosting() {
},
});
// const data = get.map((v) => ({
// ..._.omit(v, ['Forum_Komentar']),
// total_coment: v.Forum_Komentar.filter((v) => v.isActive).length,
// }));
const data = get.map((val) => ({
..._.omit(val, ["Forum_Komentar"]),
_count: val.Forum_Komentar.length,
}));
// console.log(JSON.stringify(data, null, 2));
return data;
}

View File

@@ -30,6 +30,7 @@ export async function forum_getListPostingByAuhtorId(authorId: string) {
isActive: true,
},
},
ForumMaster_StatusPosting: true
},
});

View File

@@ -25,6 +25,8 @@ export async function forum_getOnePostingById(postingId: string) {
Forum_Komentar: true,
},
},
ForumMaster_StatusPosting: true
},
});

View File

@@ -0,0 +1,50 @@
"use server"
import prisma from "@/app/lib/prisma";
import _ from "lodash"
export async function forum_funSearchListPosting(text:string) {
const get = await prisma.forum_Posting.findMany({
orderBy: [
// {
// forumMaster_StatusPostingId: "asc",
// },
{
createdAt: "desc",
},
],
take: 10,
where: {
diskusi: {
contains: text,
mode: "insensitive",
},
},
select: {
id: true,
diskusi: true,
createdAt: true,
isActive: true,
authorId: true,
Author: {
select: {
id: true,
Profile: true,
},
},
Forum_Komentar: {
where: {
isActive: true,
},
},
ForumMaster_StatusPosting: true,
},
});
const data = get.map((val) => ({
..._.omit(val, ["Forum_Komentar"]),
_count: val.Forum_Komentar.length,
}));
return data;
}

View File

@@ -30,20 +30,25 @@ import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/
export default function Forum_Komentar({
dataPosting,
userLoginId,
}: {
dataPosting: MODEL_FORUM_POSTING;
userLoginId: any
}) {
return (
<>
<Stack px={"sm"}>
<Card>
<Card.Section>
{/* <pre>{JSON.stringify(dataPosting, null, 2)}</pre> */}
<ComponentForum_PostingAuthorNameOnHeader
authorId={dataPosting?.Author?.id}
authorName={dataPosting?.Author?.Profile?.name}
imagesId={dataPosting?.Author?.Profile?.imagesId}
postingId={dataPosting?.id}
tglPublish={dataPosting?.createdAt}
statusId={dataPosting?.ForumMaster_StatusPosting?.id}
userLoginId={userLoginId}
/>
</Card.Section>
<Card.Section sx={{ zIndex: 0 }} p={"sm"}>
@@ -76,8 +81,8 @@ function CreateKomentar({ postingId }: { postingId: string }) {
if (res.status === 201) {
setLoading(true);
ComponentGlobal_NotifikasiBerhasil(res.message);
router.replace(RouterForum.main_detail + postingId, {scroll: false});
router.refresh()
router.replace(RouterForum.main_detail + postingId, { scroll: false });
router.refresh();
} else {
ComponentGlobal_NotifikasiGagal(res.message);
}

View File

@@ -14,12 +14,16 @@ import {
Divider,
Group,
Box,
TextInput,
Center,
} from "@mantine/core";
import { useShallowEffect, useTimeout, useWindowScroll } from "@mantine/hooks";
import {
IconCirclePlus,
IconMessageCircle,
IconPencilPlus,
IconSearch,
IconSearchOff,
} from "@tabler/icons-react";
import { useRouter } from "next/navigation";
import ComponentForum_PostingAuthorNameOnHeader from "../component/header/posting_author_header_name";
@@ -29,13 +33,19 @@ import { useAtom } from "jotai";
import { gs_forum_loading_edit_posting } from "../global_state";
import { MODEL_FORUM_POSTING } from "../model/interface";
import ComponentForum_MainCardView from "../component/main_card_view";
import { forum_getListAllPosting } from "../fun/get/get_list_all_posting";
import { forum_funSearchListPosting } from "../fun/search/fun_search_list_posting";
import _ from "lodash";
export default function Forum_Beranda({
listForum,
userLoginId,
}: {
listForum: MODEL_FORUM_POSTING[];
userLoginId: string;
}) {
const router = useRouter();
const [data, setData] = useState(listForum);
const [scroll, scrollTo] = useWindowScroll();
const [loadingCreate, setLoadingCreate] = useState(false);
@@ -45,9 +55,15 @@ export default function Forum_Beranda({
if (loadingDetail) return <ComponentGlobal_V2_LoadingPage />;
if (loadingKomen) return <ComponentGlobal_V2_LoadingPage />;
async function onSearch(text: string) {
await forum_funSearchListPosting(text).then((res: any) => {
setData(res);
});
}
return (
<>
{/* <pre>{JSON.stringify(listForum, null, 2)}</pre> */}
{/* <pre>{JSON.stringify(listForum, null, 2)}</pre> */}
<Affix position={{ bottom: rem(100), right: rem(30) }}>
<ActionIcon
loading={loadingCreate ? true : false}
@@ -68,67 +84,35 @@ export default function Forum_Beranda({
</ActionIcon>
</Affix>
<Box px={"sm"}>
<ComponentForum_MainCardView
data={listForum}
setLoadingKomen={setLoadingKomen}
setLoadingDetail={setLoadingDetail}
<Stack px={"sm"} spacing={"xl"}>
<TextInput
radius={"xl"}
placeholder="Topik forum apa yang anda cari hari ini ?"
onChange={(val) => {
onSearch(val.currentTarget.value);
}}
/>
</Box>
{/* <Stack px={"sm"}>
{listForum.map((e, i) => (
<Card key={i}>
<Card.Section>
<ComponentForum_PostingAuthorNameOnHeader
authorName={e?.Author?.Profile?.name}
imagesId={e?.Author?.Profile?.imagesId}
tglPublish={e?.createdAt}
isMoreButton={true}
authorId={e?.Author?.id}
postingId={e?.id}
/>
</Card.Section>
<Card.Section
sx={{ zIndex: 0 }}
p={"sm"}
onClick={() => {
// console.log("halaman forum");
setLoadingDetail(true);
router.push(RouterForum.main_detail + e.id);
}}
>
<Stack spacing={"xs"}>
<Text fz={"sm"} lineClamp={4}>
<div dangerouslySetInnerHTML={{ __html: e.diskusi }} />
</Text>
</Stack>
</Card.Section>
<Card.Section>
<Stack>
<Group spacing={"xs"} px={"sm"}>
<ActionIcon
// loading={loadingKomen ? true : false}
variant="transparent"
sx={{ zIndex: 1 }}
onClick={() => {
setLoadingKomen(true);
router.push(RouterForum.komentar + e.id);
}}
>
<IconMessageCircle color="gray" size={25} />
</ActionIcon>
<TotalKomentar postingId={e?.id} />
</Group>
<Divider />
</Stack>
</Card.Section>
</Card>
))}
</Stack> */}
{_.isEmpty(data) ? (
<Stack align="center" justify="center" h={"80vh"}>
<IconSearchOff size={80} color="gray" />
<Stack spacing={0} align="center">
<Text c={"gray"} fw={"bold"} fz={"xs"}>
Forum tidak ditemukan
</Text>
<Text c={"gray"} fw={"bold"} fz={"xs"}>
Coba masukan kata yang bebeda
</Text>
</Stack>
</Stack>
) : (
<ComponentForum_MainCardView
data={data}
setLoadingKomen={setLoadingKomen}
setLoadingDetail={setLoadingDetail}
userLoginId={userLoginId}
/>
)}
</Stack>
</>
);
}

View File

@@ -10,6 +10,9 @@ export interface MODEL_FORUM_POSTING {
authorId: string;
Author: MODEL_USER;
_count: number;
Forum_Komentar: MODEL_FORUM_KOMENTAR[];
Forum_ReportPosting: MODEL_FORUM_MASTER_REPORT[];
ForumMaster_StatusPosting: MODEL_FORUM_MASTER_STATUS;
}
export interface MODEL_FORUM_KOMENTAR {
@@ -21,9 +24,10 @@ export interface MODEL_FORUM_KOMENTAR {
forum_PostingId: string;
authorId: string;
Author: MODEL_USER;
Forum_ReportKomentar: MODEL_FORUM_MASTER_REPORT[];
}
export interface MODEL_FORUM_REPORT {
export interface MODEL_FORUM_MASTER_REPORT {
id: string;
isActive: boolean;
createdAt: Date;
@@ -31,3 +35,22 @@ export interface MODEL_FORUM_REPORT {
title: string;
deskripsi: string;
}
export interface MODEL_FORUM_MASTER_STATUS {
id: string;
isActive: boolean;
createdAt: Date;
updatedAt: Date;
status: string;
}
export interface MODEL_FORUM_REPORT {
id: string;
isActive: boolean;
createdAt: Date;
updatedAt: Date;
deskripsi: string;
ForumMaster_KategoriReport: MODEL_FORUM_MASTER_REPORT;
forumMaster_KategoriReportId: string;
User: MODEL_USER;
}

View File

@@ -1,7 +1,7 @@
"use client";
import { Box, Button, Paper, Radio, Stack, Text, Title } from "@mantine/core";
import { MODEL_FORUM_REPORT } from "../../model/interface";
import { MODEL_FORUM_MASTER_REPORT } from "../../model/interface";
import { useState } from "react";
import { forum_funCreateReportPosting } from "../../fun/create/fun_create_report_posting";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
@@ -15,7 +15,7 @@ export default function Forum_ReportKomentar({
listReport,
}: {
komentarId: string;
listReport: MODEL_FORUM_REPORT[];
listReport: MODEL_FORUM_MASTER_REPORT[];
}) {
const [reportValue, setReportValue] = useState("Kebencian");

View File

@@ -1,7 +1,7 @@
"use client";
import { Box, Button, Paper, Radio, Stack, Text, Title } from "@mantine/core";
import { MODEL_FORUM_REPORT } from "../../model/interface";
import { MODEL_FORUM_MASTER_REPORT } from "../../model/interface";
import { useState } from "react";
import { forum_funCreateReportPosting } from "../../fun/create/fun_create_report_posting";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
@@ -14,7 +14,7 @@ export default function Forum_ReportPosting({
listReport,
}: {
postingId: string;
listReport: MODEL_FORUM_REPORT[];
listReport: MODEL_FORUM_MASTER_REPORT[];
}) {
const [reportValue, setReportValue] = useState("Kebencian");

View File

@@ -0,0 +1,10 @@
[
{
"id": 1,
"status": "Open"
},
{
"id": 2,
"status": "Close"
}
]