From 11b5e8f7222d8ad09146188fa837f75c1796b19b Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Mon, 1 Jul 2024 14:26:26 +0800 Subject: [PATCH] Perbaikan UI pada Forum # style: - Tampilan keseluruhan forum di ganti menguikuti UI ## No Issue --- package.json | 2 - .../sub-detail/report-komentar/[id]/page.tsx | 10 +- .../forum/sub-menu/report-komentar/page.tsx | 12 + .../detail/{ => main-detail}/[id]/layout.tsx | 0 .../detail/{ => main-detail}/[id]/loading.tsx | 0 .../detail/{ => main-detail}/[id]/page.tsx | 8 +- .../detail/report-komentar/[id]/page.tsx | 13 + .../forum/detail/report-posting/[id]/page.tsx | 12 + src/app/dev/forum/forumku/[id]/page.tsx | 4 +- .../dev/forum/report/komentar/[id]/page.tsx | 4 + .../report/posting-lainnya/[id]/page.tsx | 9 +- .../dev/forum/report/posting/[id]/page.tsx | 4 +- src/app/dev/forum/splash/loading.tsx | 9 - src/app/dev/home/page.tsx | 2 +- src/app/emotion.tsx | 4 +- .../lib/router_admin/router_admin_forum.ts | 2 +- src/app/lib/router_hipmi/router_forum.ts | 6 +- src/app/zCoba/page.tsx | 13 +- .../forum/component/detail_one_komentar.tsx | 64 +++ .../forum/component/detail_one_posting.tsx | 8 +- .../fun/count/fun_count_laporan_komentar.ts | 3 + .../fun/count/fun_count_laporan_posting.ts | 3 + .../forum/fun/count/fun_count_publish.ts | 2 + .../forum/fun/get/get_all_report_komentar.ts | 98 +++++ ..._posting.tsx => get_all_report_posting.ts} | 0 .../forum/fun/get/get_one_komentar_by_id.ts | 31 ++ .../forum/fun/get/get_one_posting_by_id.ts | 1 + src/app_modules/admin/forum/index.tsx | 2 + .../sub_detail/hasil_report_komentar.tsx | 92 ++++- .../forum/sub_detail/hasil_report_posting.tsx | 63 ++- .../forum/sub_menu/table_report_komentar.tsx | 261 ++++++++++++ .../forum/sub_menu/table_report_posting.tsx | 37 +- src/app_modules/admin/list_page.tsx | 10 +- src/app_modules/auth/login/view.tsx | 95 ++--- src/app_modules/auth/register/view.tsx | 151 +++---- src/app_modules/auth/splash/view.tsx | 40 +- src/app_modules/auth/validasi/view.tsx | 125 +++--- src/app_modules/colab/detail/chat/index.tsx | 35 +- .../component_global/color/color_pallet.ts | 1 + .../component_layout_tamplate.tsx | 16 +- .../component_global/loading_page_v2.tsx | 4 +- .../ui/ui_header_tamplate.tsx | 89 +++++ .../ui/ui_layout_tamplate.tsx | 77 ++++ .../forum/component/beranda/beranda_card.tsx | 99 ----- .../detail_create_komentar.tsx | 119 ++++++ .../detail_component/detail_list_komentar.tsx | 82 ++++ .../detail_component/detail_view.tsx | 81 ++++ .../forumku_header.tsx} | 121 +++--- .../forumku_more_button.tsx} | 228 +++++++---- .../forumku_component/forumku_view.tsx | 88 ++++ .../komentar_author_header_name.tsx | 2 +- .../komentar_button_more.tsx | 4 +- .../component/main_component/card_header.tsx | 32 +- .../main_component/card_more_button.tsx | 52 +-- .../component/main_component/card_view.tsx | 36 +- .../more_button/posting_button_more.tsx | 6 +- src/app_modules/forum/create/index.tsx | 15 +- src/app_modules/forum/create/layout.tsx | 13 +- .../forum/detail/detail_report_komentar.tsx | 79 ++++ .../forum/detail/detail_report_posting.tsx | 61 +++ src/app_modules/forum/detail/index.tsx | 376 ------------------ src/app_modules/forum/detail/main_detail.tsx | 106 +++++ src/app_modules/forum/edit/posting/index.tsx | 18 +- src/app_modules/forum/edit/posting/layout.tsx | 12 +- .../forum/forumku/forum_profile.tsx | 100 +++++ src/app_modules/forum/forumku/index.tsx | 230 +++-------- src/app_modules/forum/forumku/layout.tsx | 17 +- .../forum/forumku/postingan_pribadi.tsx | 85 ++++ .../fun/create/fun_create_report_komentar.ts | 36 +- .../fun_create_notifikasi.tsx | 21 + ...tar_by_id.ts => get_all_komentar_by_id.ts} | 2 +- .../fun/get/get_list_posting_by_author_id.ts | 39 +- .../forum/fun/get/get_one_kategori_by_id.ts | 2 +- .../fun/get/get_one_posting_reported_by_id.ts | 46 +++ .../fun/get/get_one_report_komentar_by_id.tsx | 60 +++ src/app_modules/forum/index.ts | 8 +- src/app_modules/forum/main/beranda.tsx | 41 +- src/app_modules/forum/main/layout.tsx | 49 ++- src/app_modules/forum/model/interface.tsx | 17 +- .../forum/report/komentar/index.tsx | 87 +++- .../forum/report/komentar/lainnya.tsx | 2 +- .../forum/report/posting/index.tsx | 5 +- .../forum/report/posting/lainnya.tsx | 63 ++- src/app_modules/forum/splash/index.tsx | 45 ++- src/app_modules/home/layout.tsx | 4 +- src/app_modules/home/view.tsx | 43 +- src/app_modules/notif/index.tsx | 17 - .../fun/create/create_notif_to_admin.tsx | 3 + src/app_modules/notifikasi/main/index.tsx | 23 +- src/app_modules/zCoba/index.tsx | 2 +- yarn.lock | 36 +- 91 files changed, 2711 insertions(+), 1424 deletions(-) create mode 100644 src/app/dev/admin/forum/sub-menu/report-komentar/page.tsx rename src/app/dev/forum/detail/{ => main-detail}/[id]/layout.tsx (100%) rename src/app/dev/forum/detail/{ => main-detail}/[id]/loading.tsx (100%) rename src/app/dev/forum/detail/{ => main-detail}/[id]/page.tsx (76%) create mode 100644 src/app/dev/forum/detail/report-komentar/[id]/page.tsx create mode 100644 src/app/dev/forum/detail/report-posting/[id]/page.tsx delete mode 100644 src/app/dev/forum/splash/loading.tsx create mode 100644 src/app_modules/admin/forum/component/detail_one_komentar.tsx create mode 100644 src/app_modules/admin/forum/fun/get/get_all_report_komentar.ts rename src/app_modules/admin/forum/fun/get/{get_all_report_posting.tsx => get_all_report_posting.ts} (100%) create mode 100644 src/app_modules/admin/forum/fun/get/get_one_komentar_by_id.ts create mode 100644 src/app_modules/admin/forum/sub_menu/table_report_komentar.tsx create mode 100644 src/app_modules/component_global/ui/ui_header_tamplate.tsx create mode 100644 src/app_modules/component_global/ui/ui_layout_tamplate.tsx delete mode 100644 src/app_modules/forum/component/beranda/beranda_card.tsx create mode 100644 src/app_modules/forum/component/detail_component/detail_create_komentar.tsx create mode 100644 src/app_modules/forum/component/detail_component/detail_list_komentar.tsx create mode 100644 src/app_modules/forum/component/detail_component/detail_view.tsx rename src/app_modules/forum/component/{beranda/beranda_author_header.tsx => forumku_component/forumku_header.tsx} (52%) rename src/app_modules/forum/component/{beranda/beranda_button_more.tsx => forumku_component/forumku_more_button.tsx} (66%) create mode 100644 src/app_modules/forum/component/forumku_component/forumku_view.tsx rename src/app_modules/forum/component/{header => komentar_component}/komentar_author_header_name.tsx (97%) rename src/app_modules/forum/component/{more_button => komentar_component}/komentar_button_more.tsx (97%) create mode 100644 src/app_modules/forum/detail/detail_report_komentar.tsx create mode 100644 src/app_modules/forum/detail/detail_report_posting.tsx delete mode 100644 src/app_modules/forum/detail/index.tsx create mode 100644 src/app_modules/forum/detail/main_detail.tsx create mode 100644 src/app_modules/forum/forumku/forum_profile.tsx create mode 100644 src/app_modules/forum/forumku/postingan_pribadi.tsx create mode 100644 src/app_modules/forum/fun/forum_notifikasi/fun_create_notifikasi.tsx rename src/app_modules/forum/fun/get/{get_komentar_by_id.ts => get_all_komentar_by_id.ts} (89%) create mode 100644 src/app_modules/forum/fun/get/get_one_posting_reported_by_id.ts create mode 100644 src/app_modules/forum/fun/get/get_one_report_komentar_by_id.tsx delete mode 100644 src/app_modules/notif/index.tsx diff --git a/package.json b/package.json index 53ba7399..c1cd1e9b 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,6 @@ "@types/node": "20.4.5", "@types/react": "18.2.17", "@types/react-dom": "18.2.7", - "@types/react-virtualized": "^9.21.30", "@types/uuid": "^9.0.4", "autoprefixer": "10.4.14", "bufferutil": "^4.0.8", @@ -67,7 +66,6 @@ "react-responsive-carousel": "^3.2.23", "react-simple-toasts": "^5.10.0", "react-toastify": "^9.1.3", - "react-virtualized": "^9.22.5", "socket.io-client": "^4.7.2", "tailwindcss": "3.3.3", "ts-node": "^10.9.2", diff --git a/src/app/dev/admin/forum/sub-detail/report-komentar/[id]/page.tsx b/src/app/dev/admin/forum/sub-detail/report-komentar/[id]/page.tsx index 32d1107c..94f2bd0f 100644 --- a/src/app/dev/admin/forum/sub-detail/report-komentar/[id]/page.tsx +++ b/src/app/dev/admin/forum/sub-detail/report-komentar/[id]/page.tsx @@ -1,15 +1,23 @@ import { AdminForum_HasilReportKomentar } from "@/app_modules/admin/forum"; import { adminForum_getListReportKomentarbyId } from "@/app_modules/admin/forum/fun/get/get_list_report_komentar_by_id"; +import adminForum_funGetOneKomentarById from "@/app_modules/admin/forum/fun/get/get_one_komentar_by_id"; export default async function Page({ params }: { params: { id: string } }) { let komentarId = params.id; - const listReport = await adminForum_getListReportKomentarbyId({komentarId: komentarId, page: 1}); + const listReport = await adminForum_getListReportKomentarbyId({ + komentarId: komentarId, + page: 1, + }); + const dataKomentar = await adminForum_funGetOneKomentarById({ + komentarId: komentarId, + }); return ( <> ); diff --git a/src/app/dev/admin/forum/sub-menu/report-komentar/page.tsx b/src/app/dev/admin/forum/sub-menu/report-komentar/page.tsx new file mode 100644 index 00000000..dfff6d5b --- /dev/null +++ b/src/app/dev/admin/forum/sub-menu/report-komentar/page.tsx @@ -0,0 +1,12 @@ +import adminForum_funGetAllReportKomentar from "@/app_modules/admin/forum/fun/get/get_all_report_komentar"; +import AdminForum_TableReportKomentar from "@/app_modules/admin/forum/sub_menu/table_report_komentar"; + +export default async function Page() { + const listData = await adminForum_funGetAllReportKomentar({ page: 1 }); + + return ( + <> + + + ); +} diff --git a/src/app/dev/forum/detail/[id]/layout.tsx b/src/app/dev/forum/detail/main-detail/[id]/layout.tsx similarity index 100% rename from src/app/dev/forum/detail/[id]/layout.tsx rename to src/app/dev/forum/detail/main-detail/[id]/layout.tsx diff --git a/src/app/dev/forum/detail/[id]/loading.tsx b/src/app/dev/forum/detail/main-detail/[id]/loading.tsx similarity index 100% rename from src/app/dev/forum/detail/[id]/loading.tsx rename to src/app/dev/forum/detail/main-detail/[id]/loading.tsx diff --git a/src/app/dev/forum/detail/[id]/page.tsx b/src/app/dev/forum/detail/main-detail/[id]/page.tsx similarity index 76% rename from src/app/dev/forum/detail/[id]/page.tsx rename to src/app/dev/forum/detail/main-detail/[id]/page.tsx index 106c53ea..325d3b6b 100644 --- a/src/app/dev/forum/detail/[id]/page.tsx +++ b/src/app/dev/forum/detail/main-detail/[id]/page.tsx @@ -1,5 +1,5 @@ -import Forum_Detail from "@/app_modules/forum/detail"; -import { forum_getKomentarById } from "@/app_modules/forum/fun/get/get_komentar_by_id"; +import Forum_MainDetail from "@/app_modules/forum/detail/main_detail"; +import { forum_funGetAllKomentarById } from "@/app_modules/forum/fun/get/get_all_komentar_by_id"; import { forum_getOnePostingById } from "@/app_modules/forum/fun/get/get_one_posting_by_id"; import { forum_countOneTotalKomentarById } from "@/app_modules/forum/fun/count/count_one_total_komentar_by_id"; import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token"; @@ -11,13 +11,13 @@ export default async function Page({ params }: { params: { id: string } }) { const userLoginId = await user_getOneUserId(); const dataPosting = await forum_getOnePostingById(postingId); - const listKomentar = await forum_getKomentarById(postingId); + const listKomentar = await forum_funGetAllKomentarById(postingId); dataPosting?.isActive === false && redirect(RouterForum.beranda); return ( <> - + + + ); +} diff --git a/src/app/dev/forum/detail/report-posting/[id]/page.tsx b/src/app/dev/forum/detail/report-posting/[id]/page.tsx new file mode 100644 index 00000000..faa3d24a --- /dev/null +++ b/src/app/dev/forum/detail/report-posting/[id]/page.tsx @@ -0,0 +1,12 @@ +import { Forum_DetailReportPosting } from "@/app_modules/forum"; +import forum_funGetOneReportedPostingById from "@/app_modules/forum/fun/get/get_one_posting_reported_by_id"; + +export default async function Page({params}: {params: {id: string}}) { + const postingId = params.id + const dataPosting = await forum_funGetOneReportedPostingById({postingId: postingId}) + return ( + <> + + + ); +} diff --git a/src/app/dev/forum/forumku/[id]/page.tsx b/src/app/dev/forum/forumku/[id]/page.tsx index ca9e99b3..2432252d 100644 --- a/src/app/dev/forum/forumku/[id]/page.tsx +++ b/src/app/dev/forum/forumku/[id]/page.tsx @@ -1,5 +1,5 @@ import { Forum_Forumku } from "@/app_modules/forum"; -import { forum_getListPostingByAuhtorId } from "@/app_modules/forum/fun/get/get_list_posting_by_author_id"; +import { forum_getAllPostingByAuhtorId } from "@/app_modules/forum/fun/get/get_list_posting_by_author_id"; import { forum_countOneTotalKomentarById } from "@/app_modules/forum/fun/count/count_one_total_komentar_by_id"; import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token"; import { user_getOneByUserId } from "@/app_modules/home/fun/get/get_one_user_by_id"; @@ -25,7 +25,7 @@ export default async function Page({ params }: { params: { id: string } }) { // setTimeout(a, 1000); // }); - const dataPosting = await forum_getListPostingByAuhtorId(authorId); + const dataPosting = await forum_getAllPostingByAuhtorId({authorId: authorId, page: 1}); const totalPosting = await forum_countPostingByAuthorId(authorId); return ( diff --git a/src/app/dev/forum/report/komentar/[id]/page.tsx b/src/app/dev/forum/report/komentar/[id]/page.tsx index 64e4a7b4..88717b66 100644 --- a/src/app/dev/forum/report/komentar/[id]/page.tsx +++ b/src/app/dev/forum/report/komentar/[id]/page.tsx @@ -1,15 +1,19 @@ import { Forum_ReportKomentar } from "@/app_modules/forum"; import { forum_getMasterKategoriReport } from "@/app_modules/forum/fun/master/get_master_kategori_report"; +import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token"; export default async function Page({ params }: { params: { id: string } }) { let komentarId = params.id; const listReport = await forum_getMasterKategoriReport(); + const userLoginId = await user_getOneUserId(); + return ( <> ); diff --git a/src/app/dev/forum/report/posting-lainnya/[id]/page.tsx b/src/app/dev/forum/report/posting-lainnya/[id]/page.tsx index 0d5b8cbd..3039aef6 100644 --- a/src/app/dev/forum/report/posting-lainnya/[id]/page.tsx +++ b/src/app/dev/forum/report/posting-lainnya/[id]/page.tsx @@ -1,11 +1,16 @@ import { Forum_ReportPostingLainnya } from "@/app_modules/forum"; +import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token"; export default async function Page({ params }: { params: { id: string } }) { - let postingIg = params.id; + let postingId = params.id; + const userLoginId = await user_getOneUserId() return ( <> - + ); } diff --git a/src/app/dev/forum/report/posting/[id]/page.tsx b/src/app/dev/forum/report/posting/[id]/page.tsx index aa172433..d52c5827 100644 --- a/src/app/dev/forum/report/posting/[id]/page.tsx +++ b/src/app/dev/forum/report/posting/[id]/page.tsx @@ -1,13 +1,11 @@ import { Forum_ReportPosting } from "@/app_modules/forum"; -import { forum_getOnePostingById } from "@/app_modules/forum/fun/get/get_one_posting_by_id"; import { forum_getMasterKategoriReport } from "@/app_modules/forum/fun/master/get_master_kategori_report"; import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token"; export default async function Page({ params }: { params: { id: string } }) { let postingId = params.id; const listReport = await forum_getMasterKategoriReport(); - const userLoginId = await user_getOneUserId() - const dataPosting = await forum_getOnePostingById(postingId) + const userLoginId = await user_getOneUserId(); return ( <> diff --git a/src/app/dev/forum/splash/loading.tsx b/src/app/dev/forum/splash/loading.tsx deleted file mode 100644 index b1f8b62f..00000000 --- a/src/app/dev/forum/splash/loading.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import ComponentGlobal_V2_LoadingPage from "@/app_modules/component_global/loading_page_v2"; - -export default async function Page() { - return ( - <> - - - ); -} diff --git a/src/app/dev/home/page.tsx b/src/app/dev/home/page.tsx index e70705ff..3469f504 100644 --- a/src/app/dev/home/page.tsx +++ b/src/app/dev/home/page.tsx @@ -26,7 +26,7 @@ export default async function Page() { return ( <> - + ); } diff --git a/src/app/emotion.tsx b/src/app/emotion.tsx index 478edabf..01572366 100644 --- a/src/app/emotion.tsx +++ b/src/app/emotion.tsx @@ -1,11 +1,9 @@ "use client"; -import AppNotif from "@/app_modules/notif"; // import './globals.css' import { CacheProvider } from "@emotion/react"; -import { Image, MantineProvider, useEmotionCache } from "@mantine/core"; +import { MantineProvider, useEmotionCache } from "@mantine/core"; import { Notifications } from "@mantine/notifications"; import { useServerInsertedHTML } from "next/navigation"; -import { ToastContainer, toast } from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; export default function RootStyleRegistry({ diff --git a/src/app/lib/router_admin/router_admin_forum.ts b/src/app/lib/router_admin/router_admin_forum.ts index 9b68b6f9..0957a7b2 100644 --- a/src/app/lib/router_admin/router_admin_forum.ts +++ b/src/app/lib/router_admin/router_admin_forum.ts @@ -5,7 +5,7 @@ export const RouterAdminForum = { // sub menu table_posting: "/dev/admin/forum/sub-menu/posting", table_report_posting: "/dev/admin/forum/sub-menu/report-posting", - + table_report_komentar: "/dev/admin/forum/sub-menu/report-komentar", // detail detail_posting: "/dev/admin/forum/detail/", diff --git a/src/app/lib/router_hipmi/router_forum.ts b/src/app/lib/router_hipmi/router_forum.ts index ee955887..2666cc4b 100644 --- a/src/app/lib/router_hipmi/router_forum.ts +++ b/src/app/lib/router_hipmi/router_forum.ts @@ -13,9 +13,11 @@ export const RouterForum = { edit_komentar: "/dev/forum/edit/komentar/", //detail - main_detail: "/dev/forum/detail/", + main_detail: "/dev/forum/detail/main-detail/", + detail_report_komentar: "/dev/forum/detail/report-komentar/", + detail_report_posting: "/dev/forum/detail/report-posting/", - // komentra + // komentar komentar: "/dev/forum/komentar/", //report diff --git a/src/app/zCoba/page.tsx b/src/app/zCoba/page.tsx index d171ef0a..6cccd737 100644 --- a/src/app/zCoba/page.tsx +++ b/src/app/zCoba/page.tsx @@ -1,16 +1,17 @@ +import ComponentGlobal_HeaderTamplate from "@/app_modules/component_global/header_tamplate"; +import ComponentGlobal_UI_LayoutTamplate from "@/app_modules/component_global/ui/ui_layout_tamplate"; import Coba_TestLoading from "@/app_modules/zCoba"; +import { Text } from "@mantine/core"; export default async function Page() { - - - await new Promise((a, b) => { - setTimeout(a, 3000); - }); + await new Promise((a, b) => { + setTimeout(a, 3000); + }); return ( <> - + {/* */} ); } diff --git a/src/app_modules/admin/forum/component/detail_one_komentar.tsx b/src/app_modules/admin/forum/component/detail_one_komentar.tsx new file mode 100644 index 00000000..a2ff9e49 --- /dev/null +++ b/src/app_modules/admin/forum/component/detail_one_komentar.tsx @@ -0,0 +1,64 @@ +"use client"; + +import { MODEL_FORUM_KOMENTAR, 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_ViewOneDetailKomentar({ + dataKomentar, +}: { + dataKomentar: MODEL_FORUM_KOMENTAR; +}) { + return ( + <> + + + + Detail Komentar + + + + + + + + + Username:{" "} + + {dataKomentar?.Author?.username} + + + + + {/* */} + + + + +
+ + + + + + + ); +} diff --git a/src/app_modules/admin/forum/component/detail_one_posting.tsx b/src/app_modules/admin/forum/component/detail_one_posting.tsx index 74fe370f..13312433 100644 --- a/src/app_modules/admin/forum/component/detail_one_posting.tsx +++ b/src/app_modules/admin/forum/component/detail_one_posting.tsx @@ -21,7 +21,7 @@ export default function ComponentAdminForum_ViewOneDetailPosting({ return ( <> - + Detail Posting @@ -31,9 +31,9 @@ export default function ComponentAdminForum_ViewOneDetailPosting({ - + Username:{" "} - + {dataPosting?.Author?.username} @@ -48,7 +48,7 @@ export default function ComponentAdminForum_ViewOneDetailPosting({ {dataPosting?.ForumMaster_StatusPosting?.status} - + {/* */} diff --git a/src/app_modules/admin/forum/fun/count/fun_count_laporan_komentar.ts b/src/app_modules/admin/forum/fun/count/fun_count_laporan_komentar.ts index 9402b709..c78daf1b 100644 --- a/src/app_modules/admin/forum/fun/count/fun_count_laporan_komentar.ts +++ b/src/app_modules/admin/forum/fun/count/fun_count_laporan_komentar.ts @@ -6,6 +6,9 @@ export async function adminForum_countLaporanKomentar() { const count = await prisma.forum_ReportKomentar.count({ where: { isActive: true, + Forum_Komentar: { + isActive: true, + }, }, }); diff --git a/src/app_modules/admin/forum/fun/count/fun_count_laporan_posting.ts b/src/app_modules/admin/forum/fun/count/fun_count_laporan_posting.ts index fa673c48..9e88da10 100644 --- a/src/app_modules/admin/forum/fun/count/fun_count_laporan_posting.ts +++ b/src/app_modules/admin/forum/fun/count/fun_count_laporan_posting.ts @@ -6,6 +6,9 @@ export async function adminForum_countLaporanPosting() { const count = await prisma.forum_ReportPosting.count({ where: { isActive: true, + Forum_Posting: { + isActive: true, + }, }, }); diff --git a/src/app_modules/admin/forum/fun/count/fun_count_publish.ts b/src/app_modules/admin/forum/fun/count/fun_count_publish.ts index c5fde5de..2042cc7e 100644 --- a/src/app_modules/admin/forum/fun/count/fun_count_publish.ts +++ b/src/app_modules/admin/forum/fun/count/fun_count_publish.ts @@ -6,7 +6,9 @@ export async function adminForum_countPublish() { const count = await prisma.forum_Posting.count({ where: { isActive: true, + }, + }); return count; diff --git a/src/app_modules/admin/forum/fun/get/get_all_report_komentar.ts b/src/app_modules/admin/forum/fun/get/get_all_report_komentar.ts new file mode 100644 index 00000000..e365a254 --- /dev/null +++ b/src/app_modules/admin/forum/fun/get/get_all_report_komentar.ts @@ -0,0 +1,98 @@ +"use server"; + +import prisma from "@/app/lib/prisma"; +import { ceil } from "lodash"; + +export default async function adminForum_funGetAllReportKomentar({ + page, + search, +}: { + page: number; + search?: string; +}) { + const takeData = 10; + const skipData = page * takeData - takeData; + + const data = await prisma.forum_ReportKomentar.findMany({ + take: takeData, + skip: skipData, + orderBy: { + createdAt: "desc", + }, + where: { + Forum_Komentar: { + isActive: true, + komentar: { + 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_KomentarId: true, + Forum_Komentar: { + select: { + id: true, + komentar: 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_ReportKomentar.count({ + where: { + Forum_Komentar: { + isActive: true, + komentar: { + contains: search, + mode: "insensitive", + }, + }, + }, + }); + + const allData = { + data: data, + nPage: ceil(nCount / takeData), + }; + + return allData; +} diff --git a/src/app_modules/admin/forum/fun/get/get_all_report_posting.tsx b/src/app_modules/admin/forum/fun/get/get_all_report_posting.ts similarity index 100% rename from src/app_modules/admin/forum/fun/get/get_all_report_posting.tsx rename to src/app_modules/admin/forum/fun/get/get_all_report_posting.ts diff --git a/src/app_modules/admin/forum/fun/get/get_one_komentar_by_id.ts b/src/app_modules/admin/forum/fun/get/get_one_komentar_by_id.ts new file mode 100644 index 00000000..f1f0ff57 --- /dev/null +++ b/src/app_modules/admin/forum/fun/get/get_one_komentar_by_id.ts @@ -0,0 +1,31 @@ +"use server"; + +import prisma from "@/app/lib/prisma"; + +export default async function adminForum_funGetOneKomentarById({ + komentarId, +}: { + komentarId: string; +}) { + + const data = await prisma.forum_Komentar.findFirst({ + where: { + id: komentarId, + }, + select: { + id: true, + isActive: true, + authorId: true, + Author: { + select: { + id: true, + username: true, + }, + }, + komentar: true, + forum_PostingId: true, + }, + }); + + return data; +} diff --git a/src/app_modules/admin/forum/fun/get/get_one_posting_by_id.ts b/src/app_modules/admin/forum/fun/get/get_one_posting_by_id.ts index 2170f4f5..a84c0949 100644 --- a/src/app_modules/admin/forum/fun/get/get_one_posting_by_id.ts +++ b/src/app_modules/admin/forum/fun/get/get_one_posting_by_id.ts @@ -16,6 +16,7 @@ export async function adminForum_getOnePostingById(postingId: string) { status: true, }, }, + authorId: true, Author: { select: { id: true, diff --git a/src/app_modules/admin/forum/index.tsx b/src/app_modules/admin/forum/index.tsx index 199053be..df3d8971 100644 --- a/src/app_modules/admin/forum/index.tsx +++ b/src/app_modules/admin/forum/index.tsx @@ -4,6 +4,7 @@ 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"; +import AdminForum_TableReportKomentar from "./sub_menu/table_report_komentar"; export { AdminForum_Main, @@ -12,4 +13,5 @@ export { AdminForum_DetailPosting as AdminForum_LihatSemuaKomentar, AdminForum_HasilReportPosting, AdminForum_HasilReportKomentar, + AdminForum_TableReportKomentar, }; diff --git a/src/app_modules/admin/forum/sub_detail/hasil_report_komentar.tsx b/src/app_modules/admin/forum/sub_detail/hasil_report_komentar.tsx index 7ec2e6b9..097ed84f 100644 --- a/src/app_modules/admin/forum/sub_detail/hasil_report_komentar.tsx +++ b/src/app_modules/admin/forum/sub_detail/hasil_report_komentar.tsx @@ -6,8 +6,9 @@ import ComponentAdminDonasi_TombolKembali from "@/app_modules/admin/donasi/compo 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_KOMENTAR, MODEL_FORUM_MASTER_REPORT, - MODEL_FORUM_REPORT, + MODEL_FORUM_REPORT_POSTING, } from "@/app_modules/forum/model/interface"; import { Badge, @@ -41,22 +42,38 @@ 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"; +import ComponentAdminForum_ViewOneDetailKomentar from "../component/detail_one_komentar"; +import adminForum_funGetOneKomentarById from "../fun/get/get_one_komentar_by_id"; +import mqtt_client from "@/util/mqtt_client"; +import adminNotifikasi_funCreateToUser from "../../notifikasi/fun/create/fun_create_notif_user"; export default function AdminForum_HasilReportKomentar({ komentarId, listReport, + dataKomentar, }: { komentarId: string; listReport: any; + dataKomentar: MODEL_FORUM_KOMENTAR; }) { + const [data, setData] = useState(dataKomentar); + console.log(komentarId); + return ( <> - + { + setData(val); + }} + /> + {/*
{JSON.stringify(listReport, null, 2)}
*/}
@@ -64,23 +81,56 @@ export default function AdminForum_HasilReportKomentar({ ); } -function ButtonDeleteKomentar({ komentarId }: { komentarId: string }) { +function ButtonDeleteKomentar({ + komentarId, + data, + onSuccess, +}: { + komentarId: string; + data: MODEL_FORUM_KOMENTAR; + onSuccess: (val: any) => void; +}) { const router = useRouter(); const [opened, { open, close }] = useDisclosure(false); const [loadingDel2, setLoadingDel2] = useState(false); async function onDelete() { - await adminForum_funDeleteKomentarById(komentarId).then((res) => { + await adminForum_funDeleteKomentarById(komentarId).then(async (res) => { if (res.status === 200) { setLoadingDel2(false); close(); - router.back(); + + const dataKomentar = await adminForum_funGetOneKomentarById({ + komentarId: komentarId, + }); + onSuccess(dataKomentar); + + const dataNotif = { + appId: data.id, + status: "Report Komentar", + userId: data.authorId, + pesan: data.komentar, + kategoriApp: "FORUM", + title: "Komentar anda telah di laporkan", + }; + + const notif = await adminNotifikasi_funCreateToUser({ + data: dataNotif as any, + }); + if (notif.status === 201) { + mqtt_client.publish( + "USER", + JSON.stringify({ userId: data.authorId, count: 1 }) + ); + } + ComponentGlobal_NotifikasiBerhasil(res.message); } else { ComponentGlobal_NotifikasiGagal(res.message); } }); } + return ( <> @@ -111,17 +161,21 @@ function ButtonDeleteKomentar({ komentarId }: { komentarId: string }) {
- + {data.isActive ? ( + + ) : ( + "" + )} ); } @@ -134,7 +188,9 @@ function HasilReportPosting({ komentarId: string; }) { const router = useRouter(); - const [data, setData] = useState(listReport.data); + const [data, setData] = useState( + listReport.data + ); const [nPage, setNPage] = useState(listReport.nPage); const [activePage, setActivePage] = useState(1); const [isSearch, setSearch] = useState(""); @@ -230,7 +286,7 @@ function HasilReportPosting({
Username
-
Title
+
Kategori
Deskripsi
diff --git a/src/app_modules/admin/forum/sub_detail/hasil_report_posting.tsx b/src/app_modules/admin/forum/sub_detail/hasil_report_posting.tsx index bea6c1f9..2f3bcdf5 100644 --- a/src/app_modules/admin/forum/sub_detail/hasil_report_posting.tsx +++ b/src/app_modules/admin/forum/sub_detail/hasil_report_posting.tsx @@ -5,7 +5,7 @@ import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_glob import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal"; import { MODEL_FORUM_POSTING, - MODEL_FORUM_REPORT, + MODEL_FORUM_REPORT_POSTING, } from "@/app_modules/forum/model/interface"; import { Button, @@ -31,6 +31,8 @@ import ComponentAdminGlobal_IsEmptyData from "../../component_global/is_empty_da 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"; +import mqtt_client from "@/util/mqtt_client"; +import adminNotifikasi_funCreateToUser from "../../notifikasi/fun/create/fun_create_notif_user"; export default function AdminForum_HasilReportPosting({ dataPosting, @@ -45,7 +47,7 @@ export default function AdminForum_HasilReportPosting({ - + { - if (res.status === 200) { - setLoadingDel2(false); - setLoadingDel(false); - close(); - router.back(); - ComponentGlobal_NotifikasiBerhasil(res.message); - } else { - ComponentGlobal_NotifikasiGagal(res.message); + const del = await adminForum_funDeletePostingById(dataPosting.id); + if (del.status === 200) { + setLoadingDel2(false); + close(); + router.back(); + + const dataNotif = { + appId: dataPosting.id, + status: "Report Posting", + userId: dataPosting.authorId, + pesan: dataPosting.diskusi, + kategoriApp: "FORUM", + title: "Postingan anda telah di laporkan", + }; + const notif = await adminNotifikasi_funCreateToUser({ + data: dataNotif as any, + }); + if (notif.status === 201) { + mqtt_client.publish( + "USER", + JSON.stringify({ userId: dataPosting.authorId, count: 1 }) + ); } - }); + + ComponentGlobal_NotifikasiBerhasil(del.message); + } else { + ComponentGlobal_NotifikasiGagal(del.message); + } } return ( <> @@ -93,12 +116,13 @@ function ButtonDeletePosting({ postingId }: { postingId: string }) { radius={"xl"} onClick={() => { close(); - setLoadingDel(false); }} > Batal + + ); +} diff --git a/src/app_modules/admin/forum/sub_menu/table_report_posting.tsx b/src/app_modules/admin/forum/sub_menu/table_report_posting.tsx index 481dc1d7..0dac9b93 100644 --- a/src/app_modules/admin/forum/sub_menu/table_report_posting.tsx +++ b/src/app_modules/admin/forum/sub_menu/table_report_posting.tsx @@ -1,11 +1,9 @@ "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, + MODEL_FORUM_REPORT_POSTING } from "@/app_modules/forum/model/interface"; import { Badge, @@ -13,7 +11,6 @@ import { Button, Center, Group, - Modal, Pagination, Paper, ScrollArea, @@ -22,23 +19,15 @@ import { Table, Text, TextInput, - Title, + 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 { IconFlag3, IconSearch } 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 ComponentAdminGlobal_IsEmptyData from "../../component_global/is_empty_data"; 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, @@ -58,7 +47,7 @@ export default function AdminForum_TableReportPosting({ function TableView({ listData }: { listData: any }) { const router = useRouter(); - const [data, setData] = useState(listData.data); + const [data, setData] = useState(listData.data); const [nPage, setNPage] = useState(listData.nPage); const [activePage, setActivePage] = useState(1); const [isSearch, setSearch] = useState(""); @@ -109,7 +98,7 @@ function TableView({ listData }: { listData: any }) { - + {/*
{e?.Forum_Posting.Author.username}
@@ -130,7 +119,7 @@ function TableView({ listData }: { listData: any }) { /> - + */}
@@ -160,14 +149,14 @@ function TableView({ listData }: { listData: any }) { {/* */} - { if (val) { onLoadData(); } }} - /> + /> */} @@ -190,7 +179,7 @@ function TableView({ listData }: { listData: any }) { radius={"xl"} placeholder="Cari postingan" onChange={(val) => { - // console.log(val.currentTarget.value) + onSearch(val.currentTarget.value); }} /> @@ -218,12 +207,12 @@ function TableView({ listData }: { listData: any }) {
Jenis Laporan
- + {/*
Author
Postingan - + */}
Status Posting
diff --git a/src/app_modules/admin/list_page.tsx b/src/app_modules/admin/list_page.tsx index ae9806ee..d7e09358 100644 --- a/src/app_modules/admin/list_page.tsx +++ b/src/app_modules/admin/list_page.tsx @@ -236,11 +236,11 @@ export const listAdminPage = [ name: "Report Posting", path: RouterAdminForum.table_report_posting, }, - // { - // id: 74, - // name: "Laporan Komentar", - // path: RouterAdminForum.report_komentar, - // }, + { + id: 74, + name: "Report Komentar", + path: RouterAdminForum.table_report_komentar, + }, ], }, diff --git a/src/app_modules/auth/login/view.tsx b/src/app_modules/auth/login/view.tsx index 8b8e87c0..d345a9b6 100644 --- a/src/app_modules/auth/login/view.tsx +++ b/src/app_modules/auth/login/view.tsx @@ -1,6 +1,7 @@ "use client"; import { + BackgroundImage, Box, Button, Center, @@ -81,56 +82,56 @@ export default function Login() { return ( <> - - - - WELCOME TO - - HIPMI APPS + + + + WELCOME TO + + HIPMI APPS + + + +
+ Nomor telepon +
+ { + setPhone(val); + }} + /> + + {isError ? ( + + ) : ( + "" + )} + + +
- - -
- Nomor telepon -
- { - setPhone(val); - }} - /> - - {isError ? ( - - ) : ( - "" - )} - - -
-
+ ); } diff --git a/src/app_modules/auth/register/view.tsx b/src/app_modules/auth/register/view.tsx index 710d8b0f..59dd2e1f 100644 --- a/src/app_modules/auth/register/view.tsx +++ b/src/app_modules/auth/register/view.tsx @@ -10,8 +10,13 @@ import { Center, PinInput, Stack, + BackgroundImage, } from "@mantine/core"; -import { IconCircleLetterH, IconCloudLockOpen, IconUserCircle } from "@tabler/icons-react"; +import { + IconCircleLetterH, + IconCloudLockOpen, + IconUserCircle, +} from "@tabler/icons-react"; import { gs_nomor } from "../state/state"; import { useAtom } from "jotai"; import { useState } from "react"; @@ -28,7 +33,10 @@ import { IconPencilCheck } from "@tabler/icons-react"; import { RouterHome } from "@/app/lib/router_hipmi/router_home"; import { auth_funEditAktivasiKodeOtpById } from "../fun/fun_edit_aktivasi_kode_otp_by_id"; import ComponentGlobal_ErrorInput from "@/app_modules/component_global/error_input"; -import { AccentColor, MainColor } from "@/app_modules/component_global/color/color_pallet"; +import { + AccentColor, + MainColor, +} from "@/app_modules/component_global/color/color_pallet"; export default function Register({ dataOtp }: { dataOtp: any }) { const router = useRouter(); @@ -72,85 +80,26 @@ export default function Register({ dataOtp }: { dataOtp: any }) { return ( <> {/*
{JSON.stringify(dataOtp,null,2)}
*/} + +
+ + + REGISTRASI + -
- - - REGISTRASI - + - - - - - Anda akan terdaftar dengan nomor berikut{" "} - - +{nomor} + + + Anda akan terdaftar dengan nomor berikut{" "} + + +{nomor} + - - 0 && value.length < 5 ? ( - - ) : _.values(value).includes(" ") ? ( - - - - - ) : isValue ? ( - - ) : ( - "" - ) - } - onChange={(val) => { - val.currentTarget.value.length > 0 ? setIsValue(false) : ""; - setValue(val.currentTarget.value); - }} - /> - - - - - - - {/* -
- -
- - - - REGISTRASI - Masukan username anda ! - - - - Anda akan terdaftar dengan nomor berikut{" "} - - +{nomor} - - - - - - + + + -
*/} -
+
+
); } diff --git a/src/app_modules/auth/splash/view.tsx b/src/app_modules/auth/splash/view.tsx index b7ae6b7a..5ca2f9d8 100644 --- a/src/app_modules/auth/splash/view.tsx +++ b/src/app_modules/auth/splash/view.tsx @@ -1,12 +1,7 @@ "use client"; import { MainColor } from "@/app_modules/component_global/color/color_pallet"; -import { - Center, - Image, - Paper, - Stack -} from "@mantine/core"; +import { BackgroundImage, Center, Image, Paper, Stack } from "@mantine/core"; import { useShallowEffect } from "@mantine/hooks"; import { useRouter } from "next/navigation"; @@ -24,21 +19,28 @@ export default function SplashScreen({ data }: { data: any }) { }, 2000); } }, []); + return ( <> -
- - {/* Welcome to */} - - - - -
+ +
+ + {/* Welcome to */} + + + + +
+
); } diff --git a/src/app_modules/auth/validasi/view.tsx b/src/app_modules/auth/validasi/view.tsx index bb9c4f00..2b729418 100644 --- a/src/app_modules/auth/validasi/view.tsx +++ b/src/app_modules/auth/validasi/view.tsx @@ -11,18 +11,17 @@ import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_glob import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan"; import { ActionIcon, + BackgroundImage, Box, Button, Center, PinInput, Stack, Text, - Title + Title, } from "@mantine/core"; import { useFocusTrap } from "@mantine/hooks"; -import { - IconChevronLeft -} from "@tabler/icons-react"; +import { IconChevronLeft } from "@tabler/icons-react"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { auth_funEditAktivasiKodeOtpById } from "../fun/fun_edit_aktivasi_kode_otp_by_id"; @@ -66,64 +65,74 @@ export default function Validasi({ dataOtp }: { dataOtp: any }) { return ( <> - - - router.back()}> - - - - - - - Verifikasi Kode OTP - - - - - Masukan 4 digit kode otp - - - Yang dikirim ke +{nomor} - -
- { - setInputOtp(val); - }} - /> -
-
- + router.back()}> + + + + + + + Verifikasi Kode OTP + + + + + Masukan 4 digit kode otp + + + Yang dikirim ke{" "} + + {" "} + +{nomor} + + +
+ { + setInputOtp(val); + }} + /> +
+
+ +
-
+ ); } diff --git a/src/app_modules/colab/detail/chat/index.tsx b/src/app_modules/colab/detail/chat/index.tsx index 40e3c30d..4debaea7 100644 --- a/src/app_modules/colab/detail/chat/index.tsx +++ b/src/app_modules/colab/detail/chat/index.tsx @@ -1,52 +1,41 @@ "use client"; import { RouterColab } from "@/app/lib/router_hipmi/router_colab"; +import { evnPesan } from "@/util/evn"; +import mqtt_client from "@/util/mqtt_client"; import { ActionIcon, Box, - Button, - Card, Center, - Code, Grid, Group, - Header, Loader, Paper, - ScrollArea, Stack, Text, Textarea, - Title, + Title } from "@mantine/core"; +import { useShallowEffect } from "@mantine/hooks"; import { IconChevronLeft, IconCircle, IconInfoSquareRounded, IconSend, } from "@tabler/icons-react"; -import { useRouter } from "next/navigation"; -import router from "next/router"; -import React, { useRef, useState } from "react"; -import { - MODEL_COLLABORATION_MESSAGE, - MODEL_COLLABORATION_ROOM_CHAT, -} from "../../model/interface"; import _ from "lodash"; -import ComponentColab_IsEmptyData from "../../component/is_empty_data"; -import colab_getMessageByRoomId from "../../fun/get/room_chat/get_message_by_room_id"; -import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal"; -import colab_funCreateMessageByUserId from "../../fun/create/room/fun_create_message_by_user_id"; -import { useShallowEffect } from "@mantine/hooks"; -import mqtt_client from "@/util/mqtt_client"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; import useInfiniteScroll, { ScrollDirection, ScrollDirectionBooleanState, } from "react-easy-infinite-scroll-hook"; -import toast from "react-simple-toasts"; -import colab_getOneMessageById from "../../fun/get/room_chat/get_one_message_by_id"; -import { List } from "react-virtualized"; -import { evnPesan } from "@/util/evn"; +import ComponentColab_IsEmptyData from "../../component/is_empty_data"; +import colab_getMessageByRoomId from "../../fun/get/room_chat/get_message_by_room_id"; +import { + MODEL_COLLABORATION_MESSAGE, + MODEL_COLLABORATION_ROOM_CHAT, +} from "../../model/interface"; const list = Array(100).fill(0); export default function ColabViewChat({ diff --git a/src/app_modules/component_global/color/color_pallet.ts b/src/app_modules/component_global/color/color_pallet.ts index 9ce5fab0..15f676ba 100644 --- a/src/app_modules/component_global/color/color_pallet.ts +++ b/src/app_modules/component_global/color/color_pallet.ts @@ -8,5 +8,6 @@ export const AccentColor = { blackgray: "#333533", darkblue: "#002E59", blue: "#00447D", + skyblue: "#00BFFF", yellow: "#FFD60A", }; diff --git a/src/app_modules/component_global/component_layout_tamplate.tsx b/src/app_modules/component_global/component_layout_tamplate.tsx index 627b36c3..135d2079 100644 --- a/src/app_modules/component_global/component_layout_tamplate.tsx +++ b/src/app_modules/component_global/component_layout_tamplate.tsx @@ -1,21 +1,9 @@ "use client"; -import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog"; -import { RouterUserSearch } from "@/app/lib/router_hipmi/router_user_search"; import { Box, - Center, - Title, - SimpleGrid, - Loader, - Stack, - ActionIcon, - Avatar, - Text, + Stack } from "@mantine/core"; -import { IconUserSearch, IconUserCircle } from "@tabler/icons-react"; -import router from "next/router"; -import { ComponentGlobal_NotifikasiPeringatan } from "./notif_global/notifikasi_peringatan"; export default function AppComponentGlobal_LayoutTamplate({ children, @@ -44,7 +32,7 @@ export default function AppComponentGlobal_LayoutTamplate({ {/* Children */} - + {children} {footer ? ( diff --git a/src/app_modules/component_global/loading_page_v2.tsx b/src/app_modules/component_global/loading_page_v2.tsx index a36ab160..a2d24ec2 100644 --- a/src/app_modules/component_global/loading_page_v2.tsx +++ b/src/app_modules/component_global/loading_page_v2.tsx @@ -47,8 +47,8 @@ export default function ComponentGlobal_V2_LoadingPage() { <> diff --git a/src/app_modules/component_global/ui/ui_header_tamplate.tsx b/src/app_modules/component_global/ui/ui_header_tamplate.tsx new file mode 100644 index 00000000..22e2f794 --- /dev/null +++ b/src/app_modules/component_global/ui/ui_header_tamplate.tsx @@ -0,0 +1,89 @@ +"use client"; + +import { + Header, + Group, + ActionIcon, + Text, + Title, + Box, + Loader, +} from "@mantine/core"; +import { IconArrowLeft, IconChevronLeft } from "@tabler/icons-react"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; +import { AccentColor, MainColor } from "../color/color_pallet"; + +export default function ComponentGlobal_UI_HeaderTamplate({ + title, + // left button + hideButtonLeft, + iconLeft, + routerLeft, + // right button + iconRight, + routerRight, +}: { + title: string; + // left button + hideButtonLeft?: boolean; + iconLeft?: any; + routerLeft?: any; + // right button + iconRight?: any; + routerRight?: any; +}) { + const router = useRouter(); + const [isLoading, setIsLoading] = useState(false); + const [isRightLoading, setRightLoading] = useState(false); + + return ( + <> +
+ + { + setIsLoading(true); + routerLeft === undefined + ? router.back() + : router.push(routerLeft); + }} + > + {isLoading ? : iconLeft ? iconLeft : } + + + {title} + + + {iconRight === undefined ? ( + + ) : routerRight === undefined ? ( + {iconRight} + ) : ( + { + setRightLoading(true); + router.push(routerRight); + }} + > + {iconRight} + + )} + +
+ + ); +} diff --git a/src/app_modules/component_global/ui/ui_layout_tamplate.tsx b/src/app_modules/component_global/ui/ui_layout_tamplate.tsx new file mode 100644 index 00000000..14cc3dd5 --- /dev/null +++ b/src/app_modules/component_global/ui/ui_layout_tamplate.tsx @@ -0,0 +1,77 @@ +"use client"; + +import { BackgroundImage, Box, Center, ScrollArea } from "@mantine/core"; +import { AccentColor, MainColor } from "../color/color_pallet"; +import ComponentGlobal_HeaderTamplate from "../header_tamplate"; +import ComponentGlobal_UI_HeaderTamplate from "./ui_header_tamplate"; +import { RouterHome } from "@/app/lib/router_hipmi/router_home"; + +export default function ComponentGlobal_UI_LayoutTamplate({ + children, + header, + footer, +}: { + children: React.ReactNode; + header?: React.ReactNode; + footer?: React.ReactNode; +}) { + return ( + <> + + {/* Header */} + {header ? ( + + {header} + + ) : ( + "" + )} + + {/* Children */} + + + {/* {Array.from({ length: 100 }).map((e, i) => ( + + {i + 1} + + ))} */} + {children} + + + + {/* Footer */} + {footer ? ( + + {footer} + + ) : ( + "" + )} + + + ); +} diff --git a/src/app_modules/forum/component/beranda/beranda_card.tsx b/src/app_modules/forum/component/beranda/beranda_card.tsx deleted file mode 100644 index d0c4d57d..00000000 --- a/src/app_modules/forum/component/beranda/beranda_card.tsx +++ /dev/null @@ -1,99 +0,0 @@ -"use client"; - -import { RouterForum } from "@/app/lib/router_hipmi/router_forum"; -import { Stack, Card, Group, ActionIcon, Divider, Text } from "@mantine/core"; -import { IconMessageCircle, IconMessageCircleOff } from "@tabler/icons-react"; - - - -import { useState } from "react"; -import { useShallowEffect } from "@mantine/hooks"; -import { useRouter } from "next/navigation"; -import { useAtom } from "jotai"; - - -import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan"; -import { IconMessageCircleX } from "@tabler/icons-react"; -import { MODEL_FORUM_POSTING } from "../../model/interface"; -import ComponentForum_BerandaAuthorNameOnHeader from "./beranda_author_header"; - -export default function ComponentForum_BerandaCardView({ - data, - setData, - setLoadingKomen, - setLoadingDetail, - userLoginId, -}: { - data: MODEL_FORUM_POSTING[]; - setData: any; - setLoadingKomen: any; - setLoadingDetail: any; - userLoginId: any; -}) { - const router = useRouter(); - return ( - <> - - {data.map((e, i) => ( - - - - - - { - setLoadingDetail(true); - router.push(RouterForum.main_detail + e.id); - }} - > - -
- - - - - - - { - (e?.ForumMaster_StatusPosting.id as any) === 1 - ? (router.push(RouterForum.komentar + e?.id), - setLoadingKomen(true)) - : router.push(RouterForum.main_detail + e?.id); - }} - > - {(e?.ForumMaster_StatusPosting?.id as any) === 1 ? ( - - ) : ( - - )} - - - {/* */} - - {e?._count} - - - - - - ))} - - - ); -} diff --git a/src/app_modules/forum/component/detail_component/detail_create_komentar.tsx b/src/app_modules/forum/component/detail_component/detail_create_komentar.tsx new file mode 100644 index 00000000..64e44782 --- /dev/null +++ b/src/app_modules/forum/component/detail_component/detail_create_komentar.tsx @@ -0,0 +1,119 @@ +"use client" + +import ComponentGlobal_InputCountDown from "@/app_modules/component_global/input_countdown"; +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 notifikasiToUser_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_user"; +import { Stack, Paper, Group, Button, Divider } from "@mantine/core"; +import { useState } from "react"; +import dynamic from "next/dynamic"; +const ReactQuill = dynamic( + () => { + return import("react-quill"); + }, + { ssr: false } +); +import { forum_funCreateKomentar } from "../../fun/create/fun_create_komentar"; +import { forum_funGetAllKomentarById } from "../../fun/get/get_all_komentar_by_id"; +import { MODEL_FORUM_POSTING } from "../../model/interface"; +import { useRouter } from "next/navigation"; + +export default function ComponentForum_DetailCreateKomentar({ + postingId, + onSetKomentar, + data, + userLoginId, +}: { + postingId: string; + onSetKomentar: (val: any) => void; + data: MODEL_FORUM_POSTING; + userLoginId: string; +}) { + const router = useRouter(); + const [value, setValue] = useState(""); + const [loading, setLoading] = useState(false); + const [isEmpty, setIsEmpty] = useState(false); + + async function onComment() { + if (value.length > 500) { + return null; + } + + const createComment = await forum_funCreateKomentar(postingId, value); + if (createComment.status === 201) { + const loadKomentar = await forum_funGetAllKomentarById(data.id); + onSetKomentar(loadKomentar); + + setValue(""); + setIsEmpty(true); + ComponentGlobal_NotifikasiBerhasil(createComment.message, 2000); + + if (userLoginId !== data.Author.id) { + const dataNotif = { + appId: data.id, + userId: data.authorId, + pesan: value, + kategoriApp: "FORUM", + title: "Komentar baru", + }; + + const createNotifikasi = await notifikasiToUser_funCreate({ + data: dataNotif as any, + }); + + if (createNotifikasi.status === 201) { + mqtt_client.publish( + "USER", + JSON.stringify({ + userId: dataNotif.userId, + count: 1, + }) + ); + } + } + } else { + ComponentGlobal_NotifikasiGagal(createComment.message); + } + } + + return ( + <> + + + { + setValue(val); + }} + /> + + + + + + + + + + ); +} \ No newline at end of file diff --git a/src/app_modules/forum/component/detail_component/detail_list_komentar.tsx b/src/app_modules/forum/component/detail_component/detail_list_komentar.tsx new file mode 100644 index 00000000..c2b8eeeb --- /dev/null +++ b/src/app_modules/forum/component/detail_component/detail_list_komentar.tsx @@ -0,0 +1,82 @@ +"use client" + +import { Stack, Center, Box, Card, Spoiler, Divider, Text } from "@mantine/core"; +import _ from "lodash"; +import { MODEL_FORUM_KOMENTAR } from "../../model/interface"; +import ComponentForum_KomentarAuthorNameOnHeader from "../komentar_component/komentar_author_header_name"; + +export default function ComponentForum_ListKomentarView({ + listKomentar, + setKomentar, + postingId, + userLoginId, +}: { + listKomentar: MODEL_FORUM_KOMENTAR[]; + setKomentar: any; + postingId: string; + userLoginId: string; +}) { + return ( + <> + + {_.isEmpty(listKomentar) ? ( +
+ + Belum ada komentar + +
+ ) : ( + +
+ + {" "} + Komentar + +
+ {listKomentar.map((e, i) => ( + + + + + + + + {e.komentar ? ( + +
+ + ) : ( + "" + )} + + + + + + + + + + ))} + + )} + + + ); +} \ No newline at end of file diff --git a/src/app_modules/forum/component/detail_component/detail_view.tsx b/src/app_modules/forum/component/detail_component/detail_view.tsx new file mode 100644 index 00000000..09776292 --- /dev/null +++ b/src/app_modules/forum/component/detail_component/detail_view.tsx @@ -0,0 +1,81 @@ +"use client"; + +import { Card, Stack, Group, Text } from "@mantine/core"; +import { IconMessageCircle, IconMessageCircleX } from "@tabler/icons-react"; +import { MODEL_FORUM_POSTING } from "../../model/interface"; +import ComponentForum_DetailHeader from "./detail_header"; + +export default function ComponentForum_DetailForumView({ + data, + totalKomentar, + userLoginId, + onLoadData, +}: { + data: MODEL_FORUM_POSTING; + totalKomentar: number; + userLoginId: string; + onLoadData: (val: any) => void; +}) { + return ( + <> + + {/*
{JSON.stringify(data, null, 2)}
*/} + + {/* HEADER */} + + { + onLoadData(val); + }} + /> + + + {/* CONTENT */} + + + + {data?.diskusi ? ( +
+ ) : ( + "" + )} + + + + + {/* FOOTER */} + + + + + {(data?.ForumMaster_StatusPosting?.id as any) === 1 ? ( + + ) : ( + + )} + {totalKomentar} + + + + {new Date(data?.createdAt).toLocaleTimeString()} + {/* {new Intl.RelativeTimeFormat("id", {style: "short"}).format(-1,"day")} */} + + + {data?.createdAt + ? new Date(data?.createdAt).toLocaleDateString(["id-ID"], { + dateStyle: "medium", + }) + : new Date().toLocaleDateString(["id-ID"], { + dateStyle: "medium", + })} + + + + + + + + ); +} diff --git a/src/app_modules/forum/component/beranda/beranda_author_header.tsx b/src/app_modules/forum/component/forumku_component/forumku_header.tsx similarity index 52% rename from src/app_modules/forum/component/beranda/beranda_author_header.tsx rename to src/app_modules/forum/component/forumku_component/forumku_header.tsx index 77ddba69..89783932 100644 --- a/src/app_modules/forum/component/beranda/beranda_author_header.tsx +++ b/src/app_modules/forum/component/forumku_component/forumku_header.tsx @@ -1,79 +1,48 @@ "use client"; -import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog"; -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"; import { RouterForum } from "@/app/lib/router_hipmi/router_forum"; -import { - IconCircleFilled, - IconDots, - IconEdit, - IconFlag3, - IconMessageCircle, - IconTrash, -} from "@tabler/icons-react"; +import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog"; +import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan"; +import { Avatar, Badge, Grid, Group, Loader, Stack, Text } from "@mantine/core"; import { IconCircle } from "@tabler/icons-react"; -import { IoIosMore } from "react-icons/io"; -import { useDisclosure } from "@mantine/hooks"; +import { useRouter } from "next/navigation"; 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"; -import { data } from "autoprefixer"; -import ComponentForum_BerandaButtonMore from "./beranda_button_more"; +import { MODEL_FORUM_POSTING } from "../../model/interface"; +import ComponentForum_ForumkuMoreButton from "./forumku_more_button"; -export default function ComponentForum_BerandaAuthorNameOnHeader({ - authorId, - postingId, - imagesId, - authorName, - tglPublish, - isPembatas, + +export default function ComponentForum_ForumkuHeaderCard({ + data, isMoreButton, - statusId, userLoginId, - setData, + onLoadData, + allData, }: { - authorId?: string; - postingId?: string; - imagesId?: string; - authorName?: string; - tglPublish?: Date; - isPembatas?: boolean; - isMoreButton?: boolean; - statusId?: string; + data: MODEL_FORUM_POSTING; + isMoreButton: boolean; userLoginId: string; - setData?: any; + onLoadData: (val: any) => void; + allData: any[]; }) { const router = useRouter(); - const [loading, setLoading] = useState(false); + const [isLoading, setIsLoading] = useState(false); return ( <> - + { - if (authorId) { - setLoading(true); - router.push(RouterForum.forumku + authorId); + if (data.Author.id) { + setIsLoading(true); + router.push(RouterForum.forumku + data.Author.id); } else { ComponentGlobal_NotifikasiPeringatan("Id tidak ditemukan"); } }} > - {loading ? ( + {isLoading ? ( ) : ( @@ -91,23 +61,28 @@ export default function ComponentForum_BerandaAuthorNameOnHeader({ - + - - {authorName ? authorName : "Nama author "} + + {data.Author.username + ? data.Author.username + : "Nama author "} + - - {(statusId as any) === 1 ? "Open" : "Close"} - + {data?.ForumMaster_StatusPosting.status} @@ -115,9 +90,9 @@ export default function ComponentForum_BerandaAuthorNameOnHeader({ - - {tglPublish - ? tglPublish.toLocaleDateString(["id-ID"], { + + {data.createdAt !== undefined && data?.createdAt + ? new Date(data?.createdAt).toLocaleDateString(["id-ID"], { day: "numeric", month: "short", }) @@ -125,9 +100,10 @@ export default function ComponentForum_BerandaAuthorNameOnHeader({ day: "numeric", month: "short", })} + @@ -135,12 +111,13 @@ export default function ComponentForum_BerandaAuthorNameOnHeader({ {isMoreButton ? ( - ) : ( @@ -149,7 +126,7 @@ export default function ComponentForum_BerandaAuthorNameOnHeader({ - {isPembatas ? : ""} + {/* {isPembatas ? : ""} */} ); diff --git a/src/app_modules/forum/component/beranda/beranda_button_more.tsx b/src/app_modules/forum/component/forumku_component/forumku_more_button.tsx similarity index 66% rename from src/app_modules/forum/component/beranda/beranda_button_more.tsx rename to src/app_modules/forum/component/forumku_component/forumku_more_button.tsx index 2764b5ef..7d856de2 100644 --- a/src/app_modules/forum/component/beranda/beranda_button_more.tsx +++ b/src/app_modules/forum/component/forumku_component/forumku_more_button.tsx @@ -3,55 +3,50 @@ import { RouterForum } from "@/app/lib/router_hipmi/router_forum"; import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil"; import { - Drawer, - Stack, - Grid, - Button, - Modal, - Title, - Group, ActionIcon, - Text, - Box, - Center, + Button, + Drawer, + Grid, + Group, Loader, + Modal, + Stack, + Text, + Title, } from "@mantine/core"; -import { useDisclosure, useShallowEffect } from "@mantine/hooks"; +import { useDisclosure } from "@mantine/hooks"; import { - IconTrash, + IconDots, IconEdit, IconFlag3, - IconDots, - IconSquareRoundedX, IconSquareCheck, + IconSquareRoundedX, + IconTrash, } from "@tabler/icons-react"; import { useRouter } from "next/navigation"; import { useState } from "react"; -import { createStyles } from "@mantine/core"; -import ComponentGlobal_V2_LoadingPage from "@/app_modules/component_global/loading_page_v2"; -import { useAtom } from "jotai"; -import { gs_forum_loading_edit_posting } from "../../global_state"; -import ComponentForum_LoadingDrawer from "../loading_drawer"; -import { user_getOneUserId } 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 mqtt_client from "@/util/mqtt_client"; +import _ from "lodash"; +import { forum_funDeletePostingById } from "../../fun/delete/fun_delete_posting_by_id"; import { forum_funEditStatusPostingById } from "../../fun/edit/fun_edit_status_posting_by_id"; -import { forum_getListAllPosting } from "../../fun/get/get_list_all_posting"; -import { forum_getListPostingByAuhtorId } from "../../fun/get/get_list_posting_by_author_id"; +import { MODEL_FORUM_POSTING } from "../../model/interface"; -export default function ComponentForum_BerandaButtonMore({ +export default function ComponentForum_ForumkuMoreButton({ authorId, postingId, statusId, userLoginId, - setData, + onLoadData, + allData, }: { authorId: any; postingId?: any; statusId?: any; userLoginId: any; - setData: any; + onLoadData: (val: any) => void; + allData: any[]; }) { const router = useRouter(); @@ -177,8 +172,12 @@ export default function ComponentForum_BerandaButtonMore({ { + onLoadData(val); + }} + allData={allData} /> + {/*
{JSON.stringify(allData, null, 2)}
*/} { + onLoadData(val); + }} userLoginId={userLoginId} authorId={authorId} + allData={allData} /> - open()}> + open()}> @@ -207,11 +209,13 @@ export default function ComponentForum_BerandaButtonMore({ function ButtonDelete({ postingId, setOpenDel, - setData, + onLoadData, + allData, }: { postingId?: string; setOpenDel: any; - setData: any; + onLoadData: (val: any) => void; + allData: MODEL_FORUM_POSTING[]; }) { const [loading, setLoading] = useState(false); @@ -219,14 +223,22 @@ function ButtonDelete({ setOpenDel(false); await forum_funDeletePostingById(postingId as any).then(async (res) => { if (res.status === 200) { - // ComponentGlobal_NotifikasiBerhasil(`Postingan Terhapus`, 2000); + ComponentGlobal_NotifikasiBerhasil(`Postingan Terhapus`, 2000); setLoading(true); - const listForum = await forum_getListAllPosting(); - setData(listForum); - return null; + + const cloneData = _.clone(allData); + const hapusData = cloneData.filter((e) => e.id !== postingId); + + onLoadData(hapusData); + + mqtt_client.publish( + "Forum_hapus_data", + JSON.stringify({ + data: hapusData, + }) + ); } else { - // ComponentGlobal_NotifikasiGagal(res.message); - return null; + ComponentGlobal_NotifikasiGagal(res.message); } }); } @@ -259,16 +271,18 @@ function ButtonStatus({ postingId, setOpenStatus, statusId, - setData, + onLoadData, userLoginId, authorId, + allData, }: { postingId?: string; setOpenStatus: any; statusId?: any; - setData: any; + onLoadData: (val: any) => void; userLoginId: string; authorId: string; + allData: MODEL_FORUM_POSTING[]; }) { const [loading, setLoading] = useState(false); @@ -280,48 +294,116 @@ function ButtonStatus({ 2 ); if (upateStatusClose.status === 200) { - const loadData = await forum_getListAllPosting(); - // ComponentGlobal_NotifikasiBerhasil(`Forum Ditutup`, 2000); - setData(loadData); + ComponentGlobal_NotifikasiBerhasil(`Forum Ditutup`, 2000); setLoading(true); - return null; - } else { - // ComponentGlobal_NotifikasiGagal(upateStatusClose.message); - return null; - } - // await forum_funEditStatusPostingById(postingId as any, 2).then( - // async (res) => { - // if (res.status === 200) { - // await forum_getListAllPosting().then((val) => { - // setData(val as any); - // ComponentGlobal_NotifikasiBerhasil(`Forum Ditutup`, 2000); - // setLoading(true); - // }); - // } else { - // ComponentGlobal_NotifikasiGagal(res.message); - // } - // } - // ); + const cloneData = _.clone(allData); + const loadData = cloneData.map( + (e) => ( + e.id === postingId, + { + ...e, + ForumMaster_StatusPosting: { + id: e.id === postingId ? 2 : e.ForumMaster_StatusPosting.id, + status: + e.id === postingId + ? "Close" + : e.ForumMaster_StatusPosting.status, + }, + } + ) + ); + onLoadData(loadData); + + // + mqtt_client.publish( + "Forum_ganti_status", + JSON.stringify({ + id: postingId, + data: loadData, + }) + ); + + const findData = cloneData.find((val) => val.id === postingId); + const updateDetail = { + ...findData, + ForumMaster_StatusPosting: { + id: 2, + status: "Close", + }, + }; + + mqtt_client.publish( + "Forum_detail_ganti_status", + JSON.stringify({ + id: postingId, + data: updateDetail.ForumMaster_StatusPosting, + }) + ); + } else { + ComponentGlobal_NotifikasiGagal(upateStatusClose.message); + } } async function onBukaForum() { setOpenStatus(false); - await forum_funEditStatusPostingById(postingId as any, 1).then( - async (res) => { - if (res.status === 200) { - await forum_getListAllPosting().then((val) => { - setData(val as any); - - ComponentGlobal_NotifikasiBerhasil(`Forum Dibuka`, 2000); - setLoading(true); - }); - } else { - ComponentGlobal_NotifikasiGagal(res.message); - } - } + const updateStatusOpen = await forum_funEditStatusPostingById( + postingId as any, + 1 ); + if (updateStatusOpen.status === 200) { + ComponentGlobal_NotifikasiBerhasil(`Forum Dibuka`, 2000); + setLoading(true); + + const cloneData = _.clone(allData); + const loadData = cloneData.map( + (e) => ( + e.id === postingId, + { + ...e, + ForumMaster_StatusPosting: { + id: e.id === postingId ? 1 : e.ForumMaster_StatusPosting.id, + status: + e.id === postingId + ? "Open" + : e.ForumMaster_StatusPosting.status, + }, + } + ) + ); + + mqtt_client.publish( + "Forum_ganti_status", + JSON.stringify({ + id: postingId, + data: loadData, + }) + ); + + onLoadData(loadData); + + const findData = cloneData.find((val) => val.id === postingId); + const updateDetail = { + ...findData, + ForumMaster_StatusPosting: { + id: 1, + status: "Open", + }, + }; + + console.log(updateDetail.ForumMaster_StatusPosting); + + mqtt_client.publish( + "Forum_detail_ganti_status", + JSON.stringify({ + id: postingId, + data: updateDetail.ForumMaster_StatusPosting, + }) + ); + } else { + ComponentGlobal_NotifikasiGagal(updateStatusOpen.message); + } } return ( diff --git a/src/app_modules/forum/component/forumku_component/forumku_view.tsx b/src/app_modules/forum/component/forumku_component/forumku_view.tsx new file mode 100644 index 00000000..ed4be128 --- /dev/null +++ b/src/app_modules/forum/component/forumku_component/forumku_view.tsx @@ -0,0 +1,88 @@ +"use client"; + +import { RouterForum } from "@/app/lib/router_hipmi/router_forum"; +import { ActionIcon, Card, Divider, Group, Stack, Text } from "@mantine/core"; +import { IconMessageCircle, IconMessageCircleX } from "@tabler/icons-react"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; +import { MODEL_FORUM_POSTING } from "../../model/interface"; +import ComponentForum_ForumkuHeaderCard from "./forumku_header"; +import { AccentColor, MainColor } from "@/app_modules/component_global/color/color_pallet"; + + +export default function ComponentForum_ForumkuMainCardView({ + data, + userLoginId, + onLoadData, + allData, +}: { + data: MODEL_FORUM_POSTING; + userLoginId: string; + onLoadData: (val: any) => void; + allData: any[]; +}) { + const router = useRouter(); + const [loadingKomen, setLoadingKomen] = useState(false); + const [loadingDetail, setLoadingDetail] = useState(false); + + const [postingId, setPostingId] = useState(""); + + return ( + <> + {/*
{JSON.stringify(data, null,2)}
*/} + + + + + + { + router.push(RouterForum.main_detail + data?.id); + }} + > + +
+ + + + + + + + {(data?.ForumMaster_StatusPosting?.id as any) === 1 ? ( + + ) : ( + + )} + + + {/* */} + + {data?.Forum_Komentar.length} + + + + + + ); +} diff --git a/src/app_modules/forum/component/header/komentar_author_header_name.tsx b/src/app_modules/forum/component/komentar_component/komentar_author_header_name.tsx similarity index 97% rename from src/app_modules/forum/component/header/komentar_author_header_name.tsx rename to src/app_modules/forum/component/komentar_component/komentar_author_header_name.tsx index afc468a1..ba5f877b 100644 --- a/src/app_modules/forum/component/header/komentar_author_header_name.tsx +++ b/src/app_modules/forum/component/komentar_component/komentar_author_header_name.tsx @@ -19,7 +19,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 ComponentForum_KomentarButtonMore from "../more_button/komentar_button_more"; +import ComponentForum_KomentarButtonMore from "./komentar_button_more"; export default function ComponentForum_KomentarAuthorNameOnHeader({ userId, diff --git a/src/app_modules/forum/component/more_button/komentar_button_more.tsx b/src/app_modules/forum/component/komentar_component/komentar_button_more.tsx similarity index 97% rename from src/app_modules/forum/component/more_button/komentar_button_more.tsx rename to src/app_modules/forum/component/komentar_component/komentar_button_more.tsx index cf19e190..225e2ffd 100644 --- a/src/app_modules/forum/component/more_button/komentar_button_more.tsx +++ b/src/app_modules/forum/component/komentar_component/komentar_button_more.tsx @@ -30,7 +30,7 @@ import { user_getOneUserId } 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_funDeleteKomentarById } from "../../fun/delete/fun_delete_komentar_by_id"; -import { forum_getKomentarById } from "../../fun/get/get_komentar_by_id"; +import { forum_funGetAllKomentarById } from "../../fun/get/get_all_komentar_by_id"; export default function ComponentForum_KomentarButtonMore({ userId, @@ -178,7 +178,7 @@ function ButtonDelete({ async function onDelete() { await forum_funDeleteKomentarById(komentarId as any).then(async (res) => { if (res.status === 200) { - await forum_getKomentarById(postingId as any).then((val) => { + await forum_funGetAllKomentarById(postingId as any).then((val) => { setKomentar(val); setOpenDel(false); setLoading(true); diff --git a/src/app_modules/forum/component/main_component/card_header.tsx b/src/app_modules/forum/component/main_component/card_header.tsx index 23683649..c82ae3be 100644 --- a/src/app_modules/forum/component/main_component/card_header.tsx +++ b/src/app_modules/forum/component/main_component/card_header.tsx @@ -1,28 +1,24 @@ "use client"; -import loading from "@/app/dev/home/loading"; import { RouterForum } from "@/app/lib/router_hipmi/router_forum"; import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog"; import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan"; import { - Stack, - Loader, Avatar, Badge, - Group, - Divider, Grid, - Text, + Group, + Loader, + Stack, + Text } from "@mantine/core"; import { IconCircle } from "@tabler/icons-react"; -import ComponentForum_BerandaButtonMore from "../beranda/beranda_button_more"; -import { MODEL_USER } from "@/app_modules/home/model/interface"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { MODEL_FORUM_POSTING } from "../../model/interface"; -import ComponentForum_V2_CardMoreButton from "./card_more_button"; +import ComponentForum_BerandaMoreButton from "./card_more_button"; -export default function ComponentForum_V2_HeaderCard({ +export default function ComponentForum_BerandaHeaderCard({ data, isMoreButton, userLoginId, @@ -58,7 +54,11 @@ export default function ComponentForum_V2_HeaderCard({ ) : ( - + {data.Author.username ? data.Author.username : "Nama author "} @@ -86,7 +86,7 @@ export default function ComponentForum_V2_HeaderCard({ - + {data.createdAt !== undefined && data?.createdAt ? new Date(data?.createdAt).toLocaleDateString(["id-ID"], { day: "numeric", @@ -114,7 +114,7 @@ export default function ComponentForum_V2_HeaderCard({ @@ -122,7 +122,7 @@ export default function ComponentForum_V2_HeaderCard({ {isMoreButton ? ( - ; - return ( <> + { + setLoadingEdit(true); + router.push(RouterForum.edit_posting + postingId); + }} + > + + + + + + Edit posting{" "} + {loadingEdit ? : ""} + + + { close(); @@ -112,23 +136,6 @@ export default function ComponentForum_V2_CardMoreButton({ Hapus - - { - setLoadingEdit(true); - router.push(RouterForum.edit_posting + postingId); - }} - > - - - - - - Edit posting{" "} - {loadingEdit ? : ""} - - - )} @@ -199,7 +206,7 @@ export default function ComponentForum_V2_CardMoreButton({ /> - open()}> + open()}> @@ -237,7 +244,6 @@ function ButtonDelete({ data: hapusData, }) ); - } else { ComponentGlobal_NotifikasiGagal(res.message); } diff --git a/src/app_modules/forum/component/main_component/card_view.tsx b/src/app_modules/forum/component/main_component/card_view.tsx index 109801b0..3cdae028 100644 --- a/src/app_modules/forum/component/main_component/card_view.tsx +++ b/src/app_modules/forum/component/main_component/card_view.tsx @@ -6,9 +6,13 @@ import { IconMessageCircle, IconMessageCircleX } from "@tabler/icons-react"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { MODEL_FORUM_POSTING } from "../../model/interface"; -import ComponentForum_V2_HeaderCard from "./card_header"; +import ComponentForum_BerandaHeaderCard from "./card_header"; +import { + AccentColor, + MainColor, +} from "@/app_modules/component_global/color/color_pallet"; -export default function ComponentForum_V2_MainCardView({ +export default function ComponentForum_BerandaCardView({ data, userLoginId, onLoadData, @@ -27,10 +31,18 @@ export default function ComponentForum_V2_MainCardView({ return ( <> - {/*
{JSON.stringify(data, null,2)}
*/} - + {/*
{JSON.stringify(data, null,2)}
*/} + - - +
@@ -58,16 +70,9 @@ export default function ComponentForum_V2_MainCardView({ loading={loadingKomen && data?.id === postingId ? true : false} variant="transparent" sx={{ zIndex: 1 }} - // onClick={() => { - // setPostingId(data?.id), - // (data?.ForumMaster_StatusPosting.id as any) === 1 - // ? (router.push(RouterForum.komentar + data?.id), - // setLoadingKomen(true)) - // : router.push(RouterForum.main_detail + data?.id); - // }} > {(data?.ForumMaster_StatusPosting?.id as any) === 1 ? ( - + ) : ( )} @@ -75,9 +80,8 @@ export default function ComponentForum_V2_MainCardView({ {/* */} - {data?.Forum_Komentar.length} + {data?.Forum_Komentar.length} - diff --git a/src/app_modules/forum/component/more_button/posting_button_more.tsx b/src/app_modules/forum/component/more_button/posting_button_more.tsx index a43a40c6..e319b6ce 100644 --- a/src/app_modules/forum/component/more_button/posting_button_more.tsx +++ b/src/app_modules/forum/component/more_button/posting_button_more.tsx @@ -38,7 +38,7 @@ import { forum_funDeletePostingById } from "../../fun/delete/fun_delete_posting_ import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal"; import { forum_funEditStatusPostingById } from "../../fun/edit/fun_edit_status_posting_by_id"; import { forum_getListAllPosting } from "../../fun/get/get_list_all_posting"; -import { forum_getListPostingByAuhtorId } from "../../fun/get/get_list_posting_by_author_id"; +import { forum_getAllPostingByAuhtorId } from "../../fun/get/get_list_posting_by_author_id"; export default function ComponentForum_PostingButtonMore({ authorId, @@ -277,7 +277,7 @@ function ButtonStatus({ async (res) => { if (res.status === 200) { if (userLoginId === authorId) { - await forum_getListPostingByAuhtorId(authorId).then((val: any) => + await forum_getAllPostingByAuhtorId({authorId: authorId, page: 1}).then((val: any) => setData(val) ); } else { @@ -299,7 +299,7 @@ function ButtonStatus({ async (res) => { if (res.status === 200) { if (userLoginId === authorId) { - await forum_getListPostingByAuhtorId(authorId).then((val: any) => + await forum_getAllPostingByAuhtorId({authorId: authorId, page: 1}).then((val: any) => setData(val) ); } else { diff --git a/src/app_modules/forum/create/index.tsx b/src/app_modules/forum/create/index.tsx index c3022f64..7527041f 100644 --- a/src/app_modules/forum/create/index.tsx +++ b/src/app_modules/forum/create/index.tsx @@ -36,6 +36,10 @@ const ReactQuill = dynamic( ); import mqtt_client from "@/util/mqtt_client"; +import { + AccentColor, + MainColor, +} from "@/app_modules/component_global/color/color_pallet"; export default function Forum_Create() { const [value, setValue] = useState(""); @@ -95,8 +99,10 @@ function ButtonAction({ value }: { value: string }) { ComponentGlobal_NotifikasiBerhasil(create.message); setTimeout(() => router.back(), 1000); - mqtt_client.publish("Forum_create_new", JSON.stringify({isNewPost: true, count: 1 })); - + mqtt_client.publish( + "Forum_create_new", + JSON.stringify({ isNewPost: true, count: 1 }) + ); } else { ComponentGlobal_NotifikasiGagal(create.message); } @@ -106,7 +112,12 @@ function ButtonAction({ value }: { value: string }) { - - - - - ); -} - -function KomentarView({ - listKomentar, - setKomentar, - postingId, - userLoginId, -}: { - listKomentar: MODEL_FORUM_KOMENTAR[]; - setKomentar: any; - postingId: string; - userLoginId: string; -}) { - return ( - <> - - {_.isEmpty(listKomentar) ? ( -
- - Belum ada komentar - -
- ) : ( - -
- - {" "} - Komentar - -
- {listKomentar.map((e, i) => ( - - - - - - - - {e.komentar ? ( - -
- - ) : ( - "" - )} - - - - - - - - - - ))} - - )} - - - ); -} diff --git a/src/app_modules/forum/detail/main_detail.tsx b/src/app_modules/forum/detail/main_detail.tsx new file mode 100644 index 00000000..504b24c8 --- /dev/null +++ b/src/app_modules/forum/detail/main_detail.tsx @@ -0,0 +1,106 @@ +"use client"; + +import { + Stack +} from "@mantine/core"; +import _ from "lodash"; +import { MODEL_FORUM_KOMENTAR, MODEL_FORUM_POSTING } from "../model/interface"; + +import mqtt_client from "@/util/mqtt_client"; +import { useShallowEffect } from "@mantine/hooks"; +import { useState } from "react"; +import "react-quill/dist/quill.bubble.css"; +import ComponentForum_DetailCreateKomentar from "../component/detail_component/detail_create_komentar"; +import ComponentForum_ListKomentarView from "../component/detail_component/detail_list_komentar"; +import ComponentForum_DetailForumView from "../component/detail_component/detail_view"; + + +export default function Forum_MainDetail({ + dataPosting, + listKomentar, + userLoginId, +}: { + dataPosting: MODEL_FORUM_POSTING; + listKomentar: MODEL_FORUM_KOMENTAR[]; + userLoginId: string; +}) { + const [data, setData] = useState(dataPosting); + const [komentar, setKomentar] = useState(listKomentar); + + // useShallowEffect(() => { + // onLoadKomentar({ + // onLoad(val) { + // setKomentar(val); + // }, + // }); + // }, [setKomentar]); + + // async function onLoadKomentar({ onLoad }: { onLoad: (val: any) => void }) { + // const loadKomentar = await forum_getKomentarById(data.id); + // onLoad(loadKomentar); + // } + + useShallowEffect(() => { + mqtt_client.subscribe("Forum_detail_ganti_status"); + + mqtt_client.on("message", (topic: any, message: any) => { + const newData = JSON.parse(message.toString()); + if (newData.id === data.id) { + const cloneData = _.clone(data); + + // console.log(newData.data); + const updateData = { + ...cloneData, + ForumMaster_StatusPosting: { + id: newData.data.id, + status: newData.data.status, + }, + }; + + setData(updateData as any); + } + }); + }, [data]); + + return ( + <> + + { + setData(val); + }} + /> + + {(data?.ForumMaster_StatusPosting?.id as any) === 1 ? ( + { + setKomentar(val); + }} + data={data} + userLoginId={userLoginId} + /> + ) : ( + "" + )} + + + + + + ); +} + + + + + + diff --git a/src/app_modules/forum/edit/posting/index.tsx b/src/app_modules/forum/edit/posting/index.tsx index 65b67a2d..cf52fdfc 100644 --- a/src/app_modules/forum/edit/posting/index.tsx +++ b/src/app_modules/forum/edit/posting/index.tsx @@ -26,6 +26,10 @@ import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_glob import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal"; import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan"; import ComponentGlobal_InputCountDown from "@/app_modules/component_global/input_countdown"; +import { + AccentColor, + MainColor, +} from "@/app_modules/component_global/color/color_pallet"; const ReactQuill = dynamic( () => { return import("react-quill"); @@ -114,6 +118,17 @@ function ButtonAction({ return ( <> + + + + + ); +} diff --git a/src/app_modules/forum/forumku/index.tsx b/src/app_modules/forum/forumku/index.tsx index e246717e..065586dd 100644 --- a/src/app_modules/forum/forumku/index.tsx +++ b/src/app_modules/forum/forumku/index.tsx @@ -1,28 +1,28 @@ "use client"; import { RouterForum } from "@/app/lib/router_hipmi/router_forum"; -import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog"; -import ComponentGlobal_V2_LoadingPage from "@/app_modules/component_global/loading_page_v2"; import { MODEL_USER } from "@/app_modules/home/model/interface"; import { ActionIcon, Affix, - Avatar, - Button, Center, - Divider, - Grid, + Loader, Stack, Text, rem, } from "@mantine/core"; import { useWindowScroll } from "@mantine/hooks"; -import { IconCircleFilled, IconPencilPlus } from "@tabler/icons-react"; +import { IconPencilPlus, IconSearchOff } from "@tabler/icons-react"; import _ from "lodash"; import { useRouter } from "next/navigation"; import { useState } from "react"; -import ComponentForum_MainCardView from "../component/main_card_view"; import { MODEL_FORUM_POSTING } from "../model/interface"; +import ComponentForum_ViewForumProfile from "./forum_profile"; +import ComponentForum_PostinganPribadi from "./postingan_pribadi"; +import { ScrollOnly } from "next-scroll-loader"; +import { forum_getAllPostingByAuhtorId } from "../fun/get/get_list_posting_by_author_id"; +import ComponentForum_ForumkuMainCardView from "../component/forumku_component/forumku_view"; +import { AccentColor } from "@/app_modules/component_global/color/color_pallet"; export default function Forum_Forumku({ auhtorSelectedData, @@ -36,6 +36,9 @@ export default function Forum_Forumku({ userLoginId: string; }) { const router = useRouter(); + const [data, setData] = useState(dataPosting); + const [activePage, setActivePage] = useState(1); + const [scroll, scrollTo] = useWindowScroll(); const [loadingCreate, setLoadingCreate] = useState(false); @@ -44,21 +47,25 @@ export default function Forum_Forumku({ {userLoginId === auhtorSelectedData.id ? ( 0 ? 0.5 : ""} style={{ transition: "0.5s", + border: `1px solid ${AccentColor.skyblue}`, }} size={"xl"} radius={"xl"} variant="transparent" - bg={"blue"} + bg={AccentColor.blue} onClick={() => { setLoadingCreate(true); router.push(RouterForum.create); }} > - + {loadingCreate ? ( + + ) : ( + + )} ) : ( @@ -66,171 +73,54 @@ export default function Forum_Forumku({ )} - - {_.isEmpty(dataPosting) ? ( -
- - Belum ada posting - -
+ + {_.isEmpty(data) ? ( + + + + + Tidak ada data + + + ) : ( - + // --- Main component --- // + ( +
+ +
+ )} + data={data} + setData={setData} + moreData={async () => { + const loadData = await forum_getAllPostingByAuhtorId({ + page: activePage + 1, + authorId: auhtorSelectedData.id, + }); + setActivePage((val) => val + 1); + + return loadData; + }} + > + {(item) => ( + { + setData(val); + }} + allData={data} + /> + )} +
)}
); } - -function ForumProfile({ - auhtorSelectedData, - totalPosting, -}: { - auhtorSelectedData: MODEL_USER; - totalPosting: number; -}) { - const router = useRouter(); - const [loading, setLoading] = useState(false); - - // if (loading) return ; - - return ( - <> -
- -
- - - - - {auhtorSelectedData?.Profile?.name} - - - - - {totalPosting} Posting - - - - - @{auhtorSelectedData?.username} - {""} - - - - - - - - - - - - - - - ); -} - -function ForumPosting({ - dataPosting, - userLoginId, -}: { - dataPosting: MODEL_FORUM_POSTING[]; - userLoginId: any; -}) { - const router = useRouter(); - const [data, setData] = useState(dataPosting); - const [loadingDetail, setLoadingDetail] = useState(false); - const [loadingKomen, setLoadingKomen] = useState(false); - - if (loadingDetail) return ; - if (loadingKomen) return ; - return ( - <> - - - {/* - {dataPosting.map((e, i) => ( - - - - - { - // console.log("halaman forum"); - setLoadingDetail(true); - router.push(RouterForum.main_detail + i); - }} - > - - - Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad, - vitae. Quisquam aspernatur, eius consequatur dicta repellendus - facere vero recusandae deleniti voluptas quod architecto, - tenetur totam excepturi rem nam iusto earum. - - - - - - - { - setLoadingKomen(true); - router.push(RouterForum.komentar + i); - }} - > - - - 1 - - - - - - ))} - */} - - ); -} diff --git a/src/app_modules/forum/forumku/layout.tsx b/src/app_modules/forum/forumku/layout.tsx index a89824b6..2ea05fa3 100644 --- a/src/app_modules/forum/forumku/layout.tsx +++ b/src/app_modules/forum/forumku/layout.tsx @@ -6,6 +6,8 @@ import ComponentForum_HeaderTamplate from "../component/header/header_tamplate"; import { MODEL_USER } from "@/app_modules/home/model/interface"; import { IconX } from "@tabler/icons-react"; import AppComponentGlobal_LayoutTamplate from "@/app_modules/component_global/component_layout_tamplate"; +import ComponentGlobal_UI_LayoutTamplate from "@/app_modules/component_global/ui/ui_layout_tamplate"; +import ComponentGlobal_UI_HeaderTamplate from "@/app_modules/component_global/ui/ui_header_tamplate"; export default function LayoutForum_Forumku({ children, @@ -16,7 +18,18 @@ export default function LayoutForum_Forumku({ }) { return ( <> - } + /> + } + > + {children} + + + {/* {children} - + */} ); } diff --git a/src/app_modules/forum/forumku/postingan_pribadi.tsx b/src/app_modules/forum/forumku/postingan_pribadi.tsx new file mode 100644 index 00000000..8d654861 --- /dev/null +++ b/src/app_modules/forum/forumku/postingan_pribadi.tsx @@ -0,0 +1,85 @@ +"use client" + +import ComponentGlobal_V2_LoadingPage from "@/app_modules/component_global/loading_page_v2"; +import { useRouter } from "next/navigation"; +import { useState } from "react"; +import ComponentForum_MainCardView from "../component/main_card_view"; +import { MODEL_FORUM_POSTING } from "../model/interface"; +import ComponentForum_ForumkuMainCardView from "../component/forumku_component/forumku_view"; + +export default function ComponentForum_PostinganPribadi({ + dataPosting, + userLoginId, +}: { + dataPosting: MODEL_FORUM_POSTING[]; + userLoginId: any; +}) { + const router = useRouter(); + const [data, setData] = useState(dataPosting); + const [loadingDetail, setLoadingDetail] = useState(false); + const [loadingKomen, setLoadingKomen] = useState(false); + +// if (loadingDetail) return ; +// if (loadingKomen) return ; + + return ( + <> + + + {/* */} + + {/* + {dataPosting.map((e, i) => ( + + + + + { + // console.log("halaman forum"); + setLoadingDetail(true); + router.push(RouterForum.main_detail + i); + }} + > + + + Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad, + vitae. Quisquam aspernatur, eius consequatur dicta repellendus + facere vero recusandae deleniti voluptas quod architecto, + tenetur totam excepturi rem nam iusto earum. + + + + + + + { + setLoadingKomen(true); + router.push(RouterForum.komentar + i); + }} + > + + + 1 + + + + + + ))} + */} + + ); +} \ No newline at end of file diff --git a/src/app_modules/forum/fun/create/fun_create_report_komentar.ts b/src/app_modules/forum/fun/create/fun_create_report_komentar.ts index 9b33e379..e775f7e4 100644 --- a/src/app_modules/forum/fun/create/fun_create_report_komentar.ts +++ b/src/app_modules/forum/fun/create/fun_create_report_komentar.ts @@ -3,27 +3,35 @@ import prisma from "@/app/lib/prisma"; import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token"; -export async function forum_funCreateReportKomentar( - komentarId: string, - value: string -) { +export async function forum_funCreateReportKomentar({ + komentarId, + kategoriId, +}: { + komentarId: string; + kategoriId: any; +}) { const authorId = await user_getOneUserId(); const cekId = await prisma.forumMaster_KategoriReport.findFirst({ where: { - title: value, + title: kategoriId, }, }); - const createReport = await prisma.forum_ReportKomentar.create({ - data: { - userId: authorId, - forumMaster_KategoriReportId: cekId?.id, - forum_KomentarId: komentarId, - }, - }); + try { + const createReport = await prisma.forum_ReportKomentar.create({ + data: { + userId: authorId, + forumMaster_KategoriReportId: cekId?.id, + forum_KomentarId: komentarId, + }, + }); + + if (!createReport) + return { status: 400, message: "Gagal menambahkan report komentar !" }; + } catch (error) { + console.log(error); + } - if (!createReport) - return { status: 400, message: "Gagal menambahkan report komentar !" }; return { status: 201, message: "Berhasil me-report komentar !" }; } diff --git a/src/app_modules/forum/fun/forum_notifikasi/fun_create_notifikasi.tsx b/src/app_modules/forum/fun/forum_notifikasi/fun_create_notifikasi.tsx new file mode 100644 index 00000000..d0219a03 --- /dev/null +++ b/src/app_modules/forum/fun/forum_notifikasi/fun_create_notifikasi.tsx @@ -0,0 +1,21 @@ +"use server"; + +import prisma from "@/app/lib/prisma"; +import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface"; + +export default async function forum_funCreateNotifikasiToAdmin({ + data, +}: { + data: MODEL_NOTIFIKASI; +}) { + console.log(data); + + // const getAdmin = await prisma.user.findMany({ + // where: { + // active: true, + // masterUserRoleId: "2", + // }, + // }); + + return { status: 201 }; +} diff --git a/src/app_modules/forum/fun/get/get_komentar_by_id.ts b/src/app_modules/forum/fun/get/get_all_komentar_by_id.ts similarity index 89% rename from src/app_modules/forum/fun/get/get_komentar_by_id.ts rename to src/app_modules/forum/fun/get/get_all_komentar_by_id.ts index c60c6440..4e9bdf4e 100644 --- a/src/app_modules/forum/fun/get/get_komentar_by_id.ts +++ b/src/app_modules/forum/fun/get/get_all_komentar_by_id.ts @@ -2,7 +2,7 @@ import prisma from "@/app/lib/prisma"; -export async function forum_getKomentarById(postingId: string) { +export async function forum_funGetAllKomentarById(postingId: string) { const data = await prisma.forum_Komentar.findMany({ orderBy: { createdAt: "desc", diff --git a/src/app_modules/forum/fun/get/get_list_posting_by_author_id.ts b/src/app_modules/forum/fun/get/get_list_posting_by_author_id.ts index 7b4bd9de..bfbbb073 100644 --- a/src/app_modules/forum/fun/get/get_list_posting_by_author_id.ts +++ b/src/app_modules/forum/fun/get/get_list_posting_by_author_id.ts @@ -4,8 +4,19 @@ import prisma from "@/app/lib/prisma"; import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token"; import _ from "lodash"; -export async function forum_getListPostingByAuhtorId(authorId: string) { +export async function forum_getAllPostingByAuhtorId({ + authorId, + page, +}: { + authorId: string; + page: any; +}) { + const takeData = 5; + const skipData = page * takeData - takeData; + const get = await prisma.forum_Posting.findMany({ + take: takeData, + skip: skipData, orderBy: { createdAt: "desc", }, @@ -22,7 +33,13 @@ export async function forum_getListPostingByAuhtorId(authorId: string) { Author: { select: { id: true, - Profile: true, + username: true, + Profile: { + select: { + id: true, + imagesId: true, + }, + }, }, }, Forum_Komentar: { @@ -30,14 +47,20 @@ export async function forum_getListPostingByAuhtorId(authorId: string) { isActive: true, }, }, - ForumMaster_StatusPosting: true + ForumMaster_StatusPosting: { + select: { + id: true, + status: true, + }, + }, + forumMaster_StatusPostingId: true, }, }); - const data = get.map((val) => ({ - ..._.omit(val, ["Forum_Komentar"]), - _count: val.Forum_Komentar.length, - })); + // const data = get.map((val) => ({ + // ..._.omit(val, ["Forum_Komentar"]), + // _count: val.Forum_Komentar.length, + // })); - return data; + return get; } diff --git a/src/app_modules/forum/fun/get/get_one_kategori_by_id.ts b/src/app_modules/forum/fun/get/get_one_kategori_by_id.ts index 2acabf36..e32ce4c4 100644 --- a/src/app_modules/forum/fun/get/get_one_kategori_by_id.ts +++ b/src/app_modules/forum/fun/get/get_one_kategori_by_id.ts @@ -13,5 +13,5 @@ export default async function forum_getOneKategoriById({ }, }); - return cekData + return cekData; } diff --git a/src/app_modules/forum/fun/get/get_one_posting_reported_by_id.ts b/src/app_modules/forum/fun/get/get_one_posting_reported_by_id.ts new file mode 100644 index 00000000..7ea057dc --- /dev/null +++ b/src/app_modules/forum/fun/get/get_one_posting_reported_by_id.ts @@ -0,0 +1,46 @@ +"use server"; + +import prisma from "@/app/lib/prisma"; +import _ from "lodash"; + +export default async function forum_funGetOneReportedPostingById({ + postingId, +}: { + postingId: string; +}) { + const data = await prisma.forum_Posting.findFirst({ + where: { + id: postingId, + }, + select: { + id: true, + diskusi: true, + Forum_ReportPosting: { + select: { + id: true, + deskripsi: true, + forumMaster_KategoriReportId: true, + ForumMaster_KategoriReport: true, + }, + }, + }, + }); + + // console.log(data) + + const group = _.groupBy( + data?.Forum_ReportPosting, + (val) => val.ForumMaster_KategoriReport?.title + ); + const getKey = _.keys(group); + const filterGroup = getKey.map((e) => e.replace("undefined", "Lainnya")); + + const allData = { + data: data, + list: filterGroup, + }; + + // console.log(allData); + + return allData; +} diff --git a/src/app_modules/forum/fun/get/get_one_report_komentar_by_id.tsx b/src/app_modules/forum/fun/get/get_one_report_komentar_by_id.tsx new file mode 100644 index 00000000..36993d76 --- /dev/null +++ b/src/app_modules/forum/fun/get/get_one_report_komentar_by_id.tsx @@ -0,0 +1,60 @@ +"use server"; + +import prisma from "@/app/lib/prisma"; +import _ from "lodash"; +import { MODEL_FORUM_KOMENTAR } from "../../model/interface"; +import { group } from "console"; + +export default async function forum_funGetOneReportKomentarById({ + komentarId, +}: { + komentarId: string; +}) { + const data = await prisma.forum_Komentar.findFirst({ + where: { + id: komentarId, + }, + select: { + id: true, + komentar: true, + Forum_Posting: { + select: { + id: true, + diskusi: true, + Author: { + select: { + username: true, + }, + }, + }, + }, + + Forum_ReportKomentar: { + select: { + deskripsi: true, + ForumMaster_KategoriReport: { + select: { + id: true, + title: true, + }, + }, + }, + }, + }, + }); + + const group = _.groupBy( + data?.Forum_ReportKomentar, + (v) => v.ForumMaster_KategoriReport?.title + ); + + const getKey = _.keys(group); + const filterGroup = getKey.map((e) => e.replace("undefined", "Lainnya")); + + const allData = { + data: data, + list: filterGroup, + }; + + return allData; +} diff --git a/src/app_modules/forum/index.ts b/src/app_modules/forum/index.ts index 45d85403..99bd696a 100644 --- a/src/app_modules/forum/index.ts +++ b/src/app_modules/forum/index.ts @@ -5,7 +5,7 @@ import Forum_Forumku from "./forumku"; import Forum_Create from "./create"; import LayoutForum_Create from "./create/layout"; import LayoutForum_Forumku from "./forumku/layout"; -import Forum_Detail from "./detail"; +import Forum_MainDetail from "./detail/main_detail"; import LayoutForum_Detail from "./detail/layout"; import Forum_Komentar from "./komentar"; import LayoutForum_Komentar from "./komentar/layout"; @@ -19,6 +19,8 @@ import Forum_ReportKomentar from "./report/komentar"; import LayoutForum_ReportKomentar from "./report/komentar/layout"; import Forum_ReportPostingLainnya from "./report/posting/lainnya"; import Forum_ReportKomentarLainnya from "./report/komentar/lainnya"; +import Forum_DetailReportKomentar from "./detail/detail_report_komentar"; +import Forum_DetailReportPosting from "./detail/detail_report_posting"; export { Forum_Splash, @@ -28,7 +30,7 @@ export { Forum_Create, LayoutForum_Create, LayoutForum_Forumku, - Forum_Detail, + Forum_MainDetail as Forum_Detail, LayoutForum_Detail, Forum_Komentar, LayoutForum_Komentar, @@ -42,4 +44,6 @@ export { LayoutForum_ReportKomentar, Forum_ReportPostingLainnya, Forum_ReportKomentarLainnya, + Forum_DetailReportKomentar, + Forum_DetailReportPosting, }; diff --git a/src/app_modules/forum/main/beranda.tsx b/src/app_modules/forum/main/beranda.tsx index b83e5f04..6a1c0789 100644 --- a/src/app_modules/forum/main/beranda.tsx +++ b/src/app_modules/forum/main/beranda.tsx @@ -11,20 +11,21 @@ import { Stack, Text, TextInput, - rem + rem, } from "@mantine/core"; import { useShallowEffect, useWindowScroll } from "@mantine/hooks"; -import { - IconPencilPlus, - IconSearchOff -} from "@tabler/icons-react"; +import { IconPencilPlus, IconSearchOff } from "@tabler/icons-react"; import _ from "lodash"; import { ScrollOnly } from "next-scroll-loader"; import { useRouter } from "next/navigation"; import { useState } from "react"; -import ComponentForum_V2_MainCardView from "../component/main_component/card_view"; +import ComponentForum_BerandaCardView from "../component/main_component/card_view"; import { forum_new_getAllPosting } from "../fun/get/new_get_all_posting"; import { MODEL_FORUM_POSTING } from "../model/interface"; +import { + AccentColor, + MainColor, +} from "@/app_modules/component_global/color/color_pallet"; export default function Forum_Beranda({ listForum, @@ -121,7 +122,7 @@ export default function Forum_Beranda({ return ( <> {isNewPost && ( - + setData(val)} @@ -138,25 +139,29 @@ export default function Forum_Beranda({ {/*
{JSON.stringify(listForum, null, 2)}
*/} 0 ? 0.5 : ""} style={{ transition: "0.5s", + border: `1px solid ${AccentColor.skyblue}`, }} size={"xl"} radius={"xl"} variant="transparent" - bg={"blue"} + bg={AccentColor.blue} onClick={() => { setLoadingCreate(true); router.push(RouterForum.create); }} > - + {loadingCreate ? ( + + ) : ( + + )} - + + {_.isEmpty(data) ? ( - + - + Tidak ada data @@ -176,7 +182,7 @@ export default function Forum_Beranda({ ) : ( // --- Main component --- // (
@@ -195,7 +201,7 @@ export default function Forum_Beranda({ }} > {(item) => ( - { @@ -241,6 +247,11 @@ function ButtonUpdateBeranda({ <>
- diff --git a/src/app_modules/forum/report/posting/index.tsx b/src/app_modules/forum/report/posting/index.tsx index 650f86b6..4836e4b6 100644 --- a/src/app_modules/forum/report/posting/index.tsx +++ b/src/app_modules/forum/report/posting/index.tsx @@ -77,10 +77,9 @@ function ButtonAction({ const getKategori = await forum_getOneKategoriById({ kategoriId: toNumber(kategoriId), }); - console.log(getKategori); + // console.log(getKategori); ComponentGlobal_NotifikasiBerhasil(report.message, 2000); - setLoading(true); router.back(); const dataNotif = { @@ -99,6 +98,8 @@ function ButtonAction({ if (createNotifikasi.status === 201) { mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 })); } + setLoading(true); + } else { ComponentGlobal_NotifikasiGagal(report.message); } diff --git a/src/app_modules/forum/report/posting/lainnya.tsx b/src/app_modules/forum/report/posting/lainnya.tsx index de89b6c8..4b1fe678 100644 --- a/src/app_modules/forum/report/posting/lainnya.tsx +++ b/src/app_modules/forum/report/posting/lainnya.tsx @@ -8,11 +8,15 @@ import { forum_funCreateReportPosting } from "../../fun/create/fun_create_report 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 { forum_funCreateReportPostingLainnya } from "../../fun/create/fun_create_report_posting_lainnya"; +import mqtt_client from "@/util/mqtt_client"; +import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin"; export default function Forum_ReportPostingLainnya({ - postingIg, + postingId, + userLoginId, }: { - postingIg: string; + postingId: string; + userLoginId: string; }) { const [deskripsi, setDeskripsi] = useState(""); return ( @@ -26,46 +30,69 @@ export default function Forum_ReportPostingLainnya({ setDeskripsi(val.currentTarget.value); }} /> - + ); } function ButtonAction({ - postingIg, + postingId, deskripsi, + userLoginId, }: { - postingIg: string; + postingId: string; deskripsi: string; + userLoginId: string; }) { const router = useRouter(); async function onReport() { - await forum_funCreateReportPostingLainnya(postingIg, deskripsi).then( - (res) => { - if (res.status === 201) { - ComponentGlobal_NotifikasiBerhasil(res.message); - router.back(); - } else { - ComponentGlobal_NotifikasiGagal(res.message); - } - } + const report = await forum_funCreateReportPostingLainnya( + postingId, + deskripsi ); + if (report.status === 201) { + ComponentGlobal_NotifikasiBerhasil(report.message); + router.back(); + + const dataNotif = { + appId: postingId, + pesan: deskripsi, + kategoriApp: "FORUM", + title: "Lainnya", + userId: userLoginId, + status: "Report Posting", + }; + + const createNotifikasi = await notifikasiToAdmin_funCreate({ + data: dataNotif as any, + }); + + if (createNotifikasi.status === 201) { + mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 })); + } + } else { + ComponentGlobal_NotifikasiGagal(report.message); + } } return ( <>