From 107d4312e1bf8cc36a214839ec867533d0fd9eda Mon Sep 17 00:00:00 2001 From: bagasbanuna Date: Thu, 19 Feb 2026 16:40:35 +0800 Subject: [PATCH] Fixed UI Admin Admin Forum Pages - app/(application)/admin/forum/[id]/list-report-posting.tsx - app/(application)/admin/forum/posting.tsx - app/(application)/admin/forum/report-comment.tsx - app/(application)/admin/forum/report-posting.tsx Admin Forum Service - service/api-admin/api-admin-forum.ts Docs - docs/prompt-for-qwen-code.md New Admin Screens - screens/Admin/Forum/ ### No Issue --- .../admin/forum/[id]/list-report-posting.tsx | 284 +-------------- app/(application)/admin/forum/posting.tsx | 120 +------ .../admin/forum/report-comment.tsx | 136 +------ .../admin/forum/report-posting.tsx | 123 +------ docs/prompt-for-qwen-code.md | 17 +- .../Forum/ScreenForumDetailReportPosting.tsx | 339 ++++++++++++++++++ screens/Admin/Forum/ScreenForumPosting.tsx | 133 +++++++ .../Admin/Forum/ScreenForumReportComment.tsx | 156 ++++++++ .../Admin/Forum/ScreenForumReportPosting.tsx | 130 +++++++ service/api-admin/api-admin-forum.ts | 8 +- 10 files changed, 783 insertions(+), 663 deletions(-) create mode 100644 screens/Admin/Forum/ScreenForumDetailReportPosting.tsx create mode 100644 screens/Admin/Forum/ScreenForumPosting.tsx create mode 100644 screens/Admin/Forum/ScreenForumReportComment.tsx create mode 100644 screens/Admin/Forum/ScreenForumReportPosting.tsx diff --git a/app/(application)/admin/forum/[id]/list-report-posting.tsx b/app/(application)/admin/forum/[id]/list-report-posting.tsx index e26b625..727441b 100644 --- a/app/(application)/admin/forum/[id]/list-report-posting.tsx +++ b/app/(application)/admin/forum/[id]/list-report-posting.tsx @@ -1,283 +1,5 @@ -/* eslint-disable react-hooks/exhaustive-deps */ -import { - ActionIcon, - AlertDefaultSystem, - BadgeCustom, - BaseBox, - CenterCustom, - DrawerCustom, - LoaderCustom, - MenuDrawerDynamicGrid, - StackCustom, - TextCustom, - ViewWrapper, -} from "@/components"; -import { IconDot, IconView } from "@/components/_Icon/IconComponent"; -import { IconTrash } from "@/components/_Icon/IconTrash"; -import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle"; -import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage"; -import { GridSpan_4_8 } from "@/components/_ShareComponent/GridSpan_4_8"; -import { GridSpan_NewComponent } from "@/components/_ShareComponent/GridSpan_NewComponent"; -import { MainColor } from "@/constants/color-palet"; -import { ICON_SIZE_BUTTON } from "@/constants/constans-value"; -import { useAuth } from "@/hooks/use-auth"; -import { - apiAdminForumDeactivatePosting, - apiAdminForumListReportPostingById, - apiAdminForumPostingById, -} from "@/service/api-admin/api-admin-forum"; -import { router, useFocusEffect, useLocalSearchParams } from "expo-router"; -import _ from "lodash"; -import { useCallback, useState } from "react"; -import { View } from "react-native"; -import { Divider } from "react-native-paper"; -import Toast from "react-native-toast-message"; +import { Admin_ScreenForumDetailReportPosting } from "@/screens/Admin/Forum/ScreenForumDetailReportPosting"; -export default function AdminForumReportPosting() { - const { user } = useAuth(); - const { id } = useLocalSearchParams(); - const [openDrawerPage, setOpenDrawerPage] = useState(false); - const [openDrawerAction, setOpenDrawerAction] = useState(false); - - const [data, setData] = useState(null); - const [listReport, setListReport] = useState(null); - const [loadListReport, setLoadListReport] = useState(false); - const [selectedReport, setSelectedReport] = useState({ - id: "", - username: "", - kategori: "", - keterangan: "", - deskripsi: "", - }); - - useFocusEffect( - useCallback(() => { - onLoadData(); - }, [id]) - ); - - const onLoadData = async () => { - try { - setLoadListReport(true); - const response = await apiAdminForumPostingById({ - id: id as string, - }); - - const responseReport = await apiAdminForumListReportPostingById({ - id: id as string, - }); - - if (response.success) { - setData(response.data); - } - - if (responseReport.success) { - setListReport(responseReport.data); - } - } catch (error) { - console.log("[ERROR]", error); - } finally { - setLoadListReport(false); - } - }; - - return ( - <> - } - onPress={() => setOpenDrawerPage(true)} - /> - } - /> - } - > - - - Username} - text2={{data?.Author?.username || "-"}} - /> - - Status} - text2={ - data && data?.ForumMaster_StatusPosting?.status ? ( - - {data?.ForumMaster_StatusPosting?.status === "Open" - ? "Open" - : "Close"} - - ) : ( - {"-"} - ) - } - /> - - Postingan} - text2={{data?.diskusi || "-"}} - /> - - - - - - - Aksi - - } - text2={Pelapor} - text3={Kategori Report} - /> - - {loadListReport ? ( - - ) : _.isEmpty(listReport) ? ( - - Belum ada report - - ) : ( - listReport?.map((item: any, index: number) => ( - - - - } - onPress={() => { - setOpenDrawerAction(true); - setSelectedReport({ - id: item?.id, - username: item?.User?.username, - kategori: item?.ForumMaster_KategoriReport?.title, - keterangan: - item?.ForumMaster_KategoriReport?.deskripsi, - deskripsi: item?.deskripsi, - }); - }} - /> - - } - text2={ - - {item?.User?.username || "-"} - - } - text3={ - - {item?.ForumMaster_KategoriReport?.title || "-"} - - } - /> - - - )) - )} - - - - setOpenDrawerPage(false)} - height={"auto"} - > - , - label: "Hapus Posting", - value: "delete", - path: "", - color: MainColor.red, - }, - ]} - onPressItem={(item) => { - AlertDefaultSystem({ - title: "Hapus Posting", - message: "Apakah Anda yakin ingin menghapus posting ini?", - textLeft: "Batal", - textRight: "Hapus", - onPressRight: async () => { - const response = await apiAdminForumDeactivatePosting({ - id: id as string, - data: { - senderId: user?.id as string, - }, - }); - - if (!response.success) { - Toast.show({ - type: "error", - text1: "Posting gagal dihapus", - }); - return; - } - - setOpenDrawerPage(false); - Toast.show({ - type: "success", - text1: "Posting berhasil dihapus", - }); - router.back(); - }, - }); - }} - /> - - - setOpenDrawerAction(false)} - height={"auto"} - > - - Pelapor} - value={{selectedReport?.username || "-"}} - /> - - {selectedReport?.kategori && ( - <> - Kategori Report} - value={ - {selectedReport?.kategori || "-"} - } - /> - Keterangan} - value={ - {selectedReport?.keterangan || "-"} - } - /> - - )} - - {selectedReport?.deskripsi && ( - Deskripsi} - value={ - {selectedReport?.deskripsi || "-"} - } - /> - )} - - - - ); +export default function AdminForumDetailReportPosting() { + return ; } diff --git a/app/(application)/admin/forum/posting.tsx b/app/(application)/admin/forum/posting.tsx index dd7ad70..9693af9 100644 --- a/app/(application)/admin/forum/posting.tsx +++ b/app/(application)/admin/forum/posting.tsx @@ -1,121 +1,5 @@ -/* eslint-disable react-hooks/exhaustive-deps */ -import { - ClickableCustom, - LoaderCustom, - SearchInput, - Spacing, - StackCustom, - TextCustom, - ViewWrapper, -} from "@/components"; -import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage"; -import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage"; -import { GridSpan_4_8 } from "@/components/_ShareComponent/GridSpan_4_8"; -import { GridSpan_NewComponent } from "@/components/_ShareComponent/GridSpan_NewComponent"; -import { apiAdminForum } from "@/service/api-admin/api-admin-forum"; -import { router, useFocusEffect } from "expo-router"; -import _ from "lodash"; -import { useCallback, useState } from "react"; -import { View } from "react-native"; -import { Divider } from "react-native-paper"; +import { Admin_ScreenForumPosting } from "@/screens/Admin/Forum/ScreenForumPosting"; export default function AdminForumPosting() { - const [list, setList] = useState(null); - const [loadList, setLoadList] = useState(false); - const [search, setSearch] = useState(""); - - useFocusEffect( - useCallback(() => { - handlerLoadList(); - }, [search]) - ); - - const handlerLoadList = async () => { - try { - setLoadList(true); - const response = await apiAdminForum({ - category: "posting", - search: search, - }); - - console.log("DATA", JSON.stringify(response, null, 2)); - - if (response.success) { - setList(response.data); - } - } catch (error) { - console.log("[ERROR]", error); - } finally { - setLoadList(false); - } - }; - - const rightComponent = ( - - ); - - return ( - <> - }> - - Username} - text2={ Postingan} - text3={ Report Posting} - text4={ Komentar} - /> - - - - {loadList ? ( - - ) : _.isEmpty(list) ? ( - - Belum ada data - - ) : ( - list?.map((item: any, index: number) => ( - - { - router.push(`/admin/forum/${item.id}`); - }} - > - - {item?.Author?.username || "-"} - - } - text2={ - - {item?.diskusi || "-"} - - } - text3={ - - {item?.reportPosting || "-"} - - } - text4={ - - {item?.komentar || "-"} - - } - /> - - - - - )) - )} - - - - ); + return ; } diff --git a/app/(application)/admin/forum/report-comment.tsx b/app/(application)/admin/forum/report-comment.tsx index b9fa90f..c525a4d 100644 --- a/app/(application)/admin/forum/report-comment.tsx +++ b/app/(application)/admin/forum/report-comment.tsx @@ -1,137 +1,5 @@ -/* eslint-disable react-hooks/exhaustive-deps */ -import { - ActionIcon, - ClickableCustom, - LoaderCustom, - SearchInput, - Spacing, - StackCustom, - TextCustom, - ViewWrapper, -} from "@/components"; -import { IconView } from "@/components/_Icon/IconComponent"; -import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage"; -import AdminTitleTable from "@/components/_ShareComponent/Admin/TableTitle"; -import AdminTableValue from "@/components/_ShareComponent/Admin/TableValue"; -import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage"; -import { GridSpan_NewComponent } from "@/components/_ShareComponent/GridSpan_NewComponent"; -import { MainColor } from "@/constants/color-palet"; -import { ICON_SIZE_BUTTON } from "@/constants/constans-value"; -import { apiAdminForum } from "@/service/api-admin/api-admin-forum"; -import { router, useFocusEffect } from "expo-router"; -import _ from "lodash"; -import { useCallback, useState } from "react"; -import { View } from "react-native"; -import { Divider } from "react-native-paper"; +import { Admin_ScreenForumReportComment } from "@/screens/Admin/Forum/ScreenForumReportComment"; export default function AdminForumReportComment() { - const [listData, setListData] = useState(null); - const [loadList, setLoadList] = useState(false); - const [search, setSearch] = useState(""); - - useFocusEffect( - useCallback(() => { - onLoadData(); - }, [search]) - ); - - const onLoadData = async () => { - try { - setLoadList(true); - - const response = await apiAdminForum({ - category: "report_comment", - search: search, - }); - - if (response.success) { - setListData(response.data); - } - } catch (error) { - console.log("[ERROR]", error); - } finally { - setLoadList(false); - } - }; - - const rightComponent = ( - - ); - - return ( - <> - }> - - - - Pelapor - - } - text2={ - - Komentar - - } - text3={ - - Jenis Laporan - - } - /> - - - - {loadList ? ( - - ) : _.isEmpty(listData) ? ( - - Belum ada data - - ) : ( - listData?.map((item: any, index: number) => ( - - { - router.push( - `/admin/forum/${item?.Forum_Komentar?.id}/list-report-comment` - ); - }} - > - - {item?.User?.username || "-"} - - } - text2={ - - {item?.Forum_Komentar?.komentar || "-"} - - } - text3={ - - {item?.ForumMaster_KategoriReport?.title || "-"} - - } - /> - - - - - )) - )} - - - - ); + return ; } diff --git a/app/(application)/admin/forum/report-posting.tsx b/app/(application)/admin/forum/report-posting.tsx index a819676..c9b4146 100644 --- a/app/(application)/admin/forum/report-posting.tsx +++ b/app/(application)/admin/forum/report-posting.tsx @@ -1,124 +1,5 @@ -/* eslint-disable react-hooks/exhaustive-deps */ -import { - ActionIcon, - ClickableCustom, - Divider, - LoaderCustom, - SearchInput, - StackCustom, - TextCustom, - ViewWrapper, -} from "@/components"; -import { IconView } from "@/components/_Icon/IconComponent"; -import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage"; -import AdminTitleTable from "@/components/_ShareComponent/Admin/TableTitle"; -import AdminTableValue from "@/components/_ShareComponent/Admin/TableValue"; -import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage"; -import { GridSpan_NewComponent } from "@/components/_ShareComponent/GridSpan_NewComponent"; -import { MainColor } from "@/constants/color-palet"; -import { ICON_SIZE_BUTTON } from "@/constants/constans-value"; -import { apiAdminForum } from "@/service/api-admin/api-admin-forum"; -import { router, useFocusEffect } from "expo-router"; -import _ from "lodash"; -import { useCallback, useState } from "react"; -import { View } from "react-native"; +import { Admin_ScreenForumReportPosting } from "@/screens/Admin/Forum/ScreenForumReportPosting"; export default function AdminForumReportPosting() { - const [listData, setListData] = useState(null); - const [loadList, setLoadList] = useState(false); - const [search, setSearch] = useState(""); - - useFocusEffect( - useCallback(() => { - onLoadData(); - }, [search]) - ); - - const onLoadData = async () => { - try { - setLoadList(true); - - const response = await apiAdminForum({ - category: "report_posting", - search: search, - }); - - if (response.success) { - setListData(response.data); - } - } catch (error) { - console.log("[ERROR]", error); - } finally { - setLoadList(false); - } - }; - - const rightComponent = ( - - ); - - return ( - <> - }> - - - - Pelapor - - } - text2={ - - Postingan - - } - /> - - - {loadList ? ( - - ) : _.isEmpty(listData) ? ( - - Belum ada data - - ) : ( - listData?.map((item: any, index: number) => ( - - { - router.push( - `/admin/forum/${item?.Forum_Posting?.id}/list-report-posting` - ); - }} - > - - {item?.User?.username || "-"} - - } - text2={ - - {item?.Forum_Posting?.diskusi || "-"} - - } - /> - - - - )) - )} - - - - ); + return ; } diff --git a/docs/prompt-for-qwen-code.md b/docs/prompt-for-qwen-code.md index 97b34f2..d640487 100644 --- a/docs/prompt-for-qwen-code.md +++ b/docs/prompt-for-qwen-code.md @@ -55,10 +55,10 @@ Component yang digunakan: components/_ShareComponent/NewWrapper.tsx -File source: app/(application)/admin/investment/[id]/list-of-investor.tsx -Folder tujuan: screens/Admin/Investment -Nama file utama: ScreenInvestmentListOfInvestor.tsx -Nama function utama: Admin_ScreenInvestmentListOfInvestor +File source: app/(application)/admin/forum/[id]/list-report-posting.tsx +Folder tujuan: screens/Admin/Forum +Nama file utama: ScreenForumDetailReportPosting.tsx +Nama function utama: Admin_ScreenForumDetailReportPosting File komponen wrapper: components/_ShareComponent/NewWrapper.tsx Buat file baru pada "Folder tujuan" dengan nama "Nama file utama" dan ubah nama function menjadi "Nama function utama" kemudian clean code, import dan panggil function tersebut pada file "File source" @@ -66,8 +66,8 @@ Analisa juga file "Nama file utama" , jika belum menggunakan NewWrapper pada fil -Function fecth: apiAdminInvestmentListOfInvestor -File function fetch: service/api-admin/api-admin-investment.ts +Function fecth: apiAdminForumListReportPostingById +File function fetch: service/api-admin/api-admin-forum.ts Terapkan pagination pada file "Nama file utama" Komponen pagination yang digunaka berada pada file hooks/use-pagination.tsx dan helpers/paginationHelpers.tsx @@ -80,11 +80,14 @@ Gunakan bahasa indonesia pada cli agar saya mudah membacanya. -File refrensi: screens/Admin/Donation/ScreenDonationListOfDonatur.tsx +File refrensi: screens/Admin/Forum/ScreenForumReportPosting.tsx Anda bisa menggunakan refrensi dari "File refrensi" jika butuh pemahaman dengan tipe fitur yang hampir sama Untuk refrensi tampilan Box bisa anda gunakan dari file: screens/Admin/Donation/BoxDonationListOfDonatur.tsx dan buatkan komponen yang mirip untuk list of donatur dengan nama file: BoxDonationListOfInvestor.tsx + + + Terapkan NewWrapper pada file: screens/Admin/App-Information/InformationBankSection.tsx Component yang digunakan: components/_ShareComponent/NewWrapper.tsx diff --git a/screens/Admin/Forum/ScreenForumDetailReportPosting.tsx b/screens/Admin/Forum/ScreenForumDetailReportPosting.tsx new file mode 100644 index 0000000..b254ffd --- /dev/null +++ b/screens/Admin/Forum/ScreenForumDetailReportPosting.tsx @@ -0,0 +1,339 @@ +/* eslint-disable react-hooks/exhaustive-deps */ +import { + ActionIcon, + AlertDefaultSystem, + BadgeCustom, + BaseBox, + CenterCustom, + DrawerCustom, + MenuDrawerDynamicGrid, + StackCustom, + TextCustom, +} from "@/components"; +import { IconDot, IconView } from "@/components/_Icon/IconComponent"; +import { IconTrash } from "@/components/_Icon/IconTrash"; +import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle"; +import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage"; +import { GridSpan_4_8 } from "@/components/_ShareComponent/GridSpan_4_8"; +import { GridSpan_NewComponent } from "@/components/_ShareComponent/GridSpan_NewComponent"; +import NewWrapper from "@/components/_ShareComponent/NewWrapper"; +import { MainColor } from "@/constants/color-palet"; +import { + ICON_SIZE_BUTTON, + PAGINATION_DEFAULT_TAKE, +} from "@/constants/constans-value"; +import { createPaginationComponents } from "@/helpers/paginationHelpers"; +import { usePagination } from "@/hooks/use-pagination"; +import { useAuth } from "@/hooks/use-auth"; +import { + apiAdminForumDeactivatePosting, + apiAdminForumListReportPostingById, + apiAdminForumPostingById, +} from "@/service/api-admin/api-admin-forum"; +import { router, useFocusEffect, useLocalSearchParams } from "expo-router"; +import _ from "lodash"; +import { useCallback, useMemo, useState } from "react"; +import { RefreshControl, View } from "react-native"; +import { Divider } from "react-native-paper"; +import Toast from "react-native-toast-message"; + +export function Admin_ScreenForumDetailReportPosting() { + const { user } = useAuth(); + const { id } = useLocalSearchParams(); + const [openDrawerPage, setOpenDrawerPage] = useState(false); + const [openDrawerAction, setOpenDrawerAction] = useState(false); + const [data, setData] = useState(null); + const [selectedReport, setSelectedReport] = useState({ + id: "", + username: "", + kategori: "", + keterangan: "", + deskripsi: "", + }); + + // Load data postingan saat screen fokus + useFocusEffect( + useCallback(() => { + onLoadDataPosting(); + }, [id]) + ); + + // Pagination untuk list report + const pagination = usePagination({ + fetchFunction: async (page, searchQuery) => { + const response = await apiAdminForumListReportPostingById({ + id: id as string, + page: String(page), + }); + + if (response.success) { + return { data: response.data }; + } + return { data: [] }; + }, + pageSize: PAGINATION_DEFAULT_TAKE, + dependencies: [id], + }); + + const onLoadDataPosting = async () => { + try { + const response = await apiAdminForumPostingById({ + id: id as string, + }); + + if (response.success) { + setData(response.data); + } + } catch (error) { + console.log("[ERROR]", error); + } + }; + + // Render item untuk daftar report + const renderItem = useCallback( + ({ item }: { item: any }) => ( + + + } + onPress={() => { + setOpenDrawerAction(true); + setSelectedReport({ + id: item?.id, + username: item?.User?.username, + kategori: item?.ForumMaster_KategoriReport?.title, + keterangan: item?.ForumMaster_KategoriReport?.deskripsi, + deskripsi: item?.deskripsi, + }); + }} + /> + + } + text2={ + + {item?.User?.username || "-"} + + } + text3={ + + {item?.ForumMaster_KategoriReport?.title || "-"} + + } + /> + + + ), + [] + ); + + // Header component dengan detail postingan + const headerComponent = useMemo( + () => ( + } + onPress={() => setOpenDrawerPage(true)} + /> + } + /> + ), + [] + ); + + // Detail postingan component + const postingDetailComponent = useMemo( + () => ( + + + Username} + text2={{data?.Author?.username || "-"}} + /> + + Status} + text2={ + data && data?.ForumMaster_StatusPosting?.status ? ( + + {data?.ForumMaster_StatusPosting?.status === "Open" + ? "Open" + : "Close"} + + ) : ( + {"-"} + ) + } + /> + + Postingan} + text2={{data?.diskusi || "-"}} + /> + + + ), + [data] + ); + + // Box title untuk daftar report + const reportListTitleComponent = useMemo( + () => , + [] + ); + + // Header untuk kolom daftar report + const reportListHeaderComponent = useMemo( + () => ( + + {postingDetailComponent} + {reportListTitleComponent} + + Aksi + + } + text2={Pelapor} + text3={Kategori Report} + /> + + + ), + [postingDetailComponent, reportListTitleComponent] + ); + + // Buat komponen-komponen pagination + const { ListEmptyComponent, ListFooterComponent } = + createPaginationComponents({ + loading: pagination.loading, + refreshing: pagination.refreshing, + listData: pagination.listData, + emptyMessage: "Belum ada report", + emptySearchMessage: "Tidak ada hasil pencarian", + isInitialLoad: pagination.isInitialLoad, + skeletonCount: PAGINATION_DEFAULT_TAKE, + skeletonHeight: 100, + }); + + return ( + <> + + } + /> + + {/* Drawer untuk menu halaman (hapus posting) */} + setOpenDrawerPage(false)} + height={"auto"} + > + , + label: "Hapus Posting", + value: "delete", + path: "", + color: MainColor.red, + }, + ]} + onPressItem={(item) => { + AlertDefaultSystem({ + title: "Hapus Posting", + message: "Apakah Anda yakin ingin menghapus posting ini?", + textLeft: "Batal", + textRight: "Hapus", + onPressRight: async () => { + const response = await apiAdminForumDeactivatePosting({ + id: id as string, + data: { + senderId: user?.id as string, + }, + }); + + if (!response.success) { + Toast.show({ + type: "error", + text1: "Posting gagal dihapus", + }); + return; + } + + setOpenDrawerPage(false); + Toast.show({ + type: "success", + text1: "Posting berhasil dihapus", + }); + router.back(); + }, + }); + }} + /> + + + {/* Drawer untuk detail report */} + setOpenDrawerAction(false)} + height={"auto"} + > + + Pelapor} + value={{selectedReport?.username || "-"}} + /> + + {selectedReport?.kategori && ( + <> + Kategori Report} + value={ + {selectedReport?.kategori || "-"} + } + /> + Keterangan} + value={ + {selectedReport?.keterangan || "-"} + } + /> + + )} + + {selectedReport?.deskripsi && ( + Deskripsi} + value={ + {selectedReport?.deskripsi || "-"} + } + /> + )} + + + + ); +} diff --git a/screens/Admin/Forum/ScreenForumPosting.tsx b/screens/Admin/Forum/ScreenForumPosting.tsx new file mode 100644 index 0000000..0fa8087 --- /dev/null +++ b/screens/Admin/Forum/ScreenForumPosting.tsx @@ -0,0 +1,133 @@ +import { + SearchInput, StackCustom, + TextCustom +} from "@/components"; +import AdminBasicBox from "@/components/_ShareComponent/Admin/AdminBasicBox"; +import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage"; +import { GridSpan_4_8 } from "@/components/_ShareComponent/GridSpan_4_8"; +import NewWrapper from "@/components/_ShareComponent/NewWrapper"; +import { MainColor } from "@/constants/color-palet"; +import { PAGINATION_DEFAULT_TAKE } from "@/constants/constans-value"; +import { createPaginationComponents } from "@/helpers/paginationHelpers"; +import { usePagination } from "@/hooks/use-pagination"; +import { apiAdminForum } from "@/service/api-admin/api-admin-forum"; +import { router } from "expo-router"; +import { useCallback, useMemo, useState } from "react"; +import { RefreshControl, View } from "react-native"; +import { Divider } from "react-native-paper"; + +export function Admin_ScreenForumPosting() { + const [search, setSearch] = useState(""); + + // Gunakan hook pagination + const pagination = usePagination({ + fetchFunction: async (page, searchQuery) => { + const response = await apiAdminForum({ + category: "posting", + search: searchQuery || "", + page: String(page), + }); + + if (response.success) { + return { data: response.data }; + } else { + return { data: [] }; + } + }, + pageSize: PAGINATION_DEFAULT_TAKE, + searchQuery: search, + dependencies: [], + }); + + // Komponen search input + const searchComponent = useMemo( + () => ( + + ), + [search], + ); + + // Header component + const headerComponent = useMemo( + () => ( + + ), + [searchComponent], + ); + + // Render item untuk daftar posting + const renderItem = useCallback( + ({ item, index }: { item: any; index: number }) => ( + { + router.push(`/admin/forum/${item.id}`); + }} + > + + + + {item?.diskusi || "-"} + + + + Komentar} + value={ + {item?.komentar || "-"} + } + /> + Report} + value={ + {item?.reportPosting || "-"} + } + /> + + + ), + [], + ); + + // Buat komponen-komponen pagination + const { ListEmptyComponent, ListFooterComponent } = + createPaginationComponents({ + loading: pagination.loading, + refreshing: pagination.refreshing, + listData: pagination.listData, + searchQuery: search, + emptyMessage: "Belum ada data posting", + emptySearchMessage: "Tidak ada hasil pencarian", + isInitialLoad: pagination.isInitialLoad, + skeletonCount: PAGINATION_DEFAULT_TAKE, + skeletonHeight: 100, + }); + + return ( + item.id?.toString() || `fallback-${item.id}`} + headerComponent={headerComponent} + ListEmptyComponent={ListEmptyComponent} + ListFooterComponent={ListFooterComponent} + onEndReached={pagination.loadMore} + refreshControl={ + + } + /> + ); +} diff --git a/screens/Admin/Forum/ScreenForumReportComment.tsx b/screens/Admin/Forum/ScreenForumReportComment.tsx new file mode 100644 index 0000000..f306a77 --- /dev/null +++ b/screens/Admin/Forum/ScreenForumReportComment.tsx @@ -0,0 +1,156 @@ +import { SearchInput, StackCustom, TextCustom } from "@/components"; +import AdminBasicBox from "@/components/_ShareComponent/Admin/AdminBasicBox"; +import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage"; +import { GridSpan_4_8 } from "@/components/_ShareComponent/GridSpan_4_8"; +import NewWrapper from "@/components/_ShareComponent/NewWrapper"; +import { PAGINATION_DEFAULT_TAKE } from "@/constants/constans-value"; +import { createPaginationComponents } from "@/helpers/paginationHelpers"; +import { usePagination } from "@/hooks/use-pagination"; +import { apiAdminForum } from "@/service/api-admin/api-admin-forum"; +import { router } from "expo-router"; +import { useCallback, useMemo, useState } from "react"; +import { RefreshControl } from "react-native"; +import { Divider } from "react-native-paper"; + +export function Admin_ScreenForumReportComment() { + const [search, setSearch] = useState(""); + + // Gunakan hook pagination + const pagination = usePagination({ + fetchFunction: async (page, searchQuery) => { + const response = await apiAdminForum({ + category: "report_comment", + search: searchQuery || "", + page: String(page), + }); + + if (response.success) { + console.log("CEK", JSON.stringify(response.data, null, 2)); + return { data: response.data }; + } else { + return { data: [] }; + } + }, + pageSize: PAGINATION_DEFAULT_TAKE, + searchQuery: search, + dependencies: [], + }); + + // Komponen search input + const searchComponent = useMemo( + () => ( + + ), + [search], + ); + + // Header component dengan box title + const headerComponent = useMemo( + () => ( + + ), + [searchComponent], + ); + + // Render item untuk daftar report comment + const renderItem = useCallback( + ({ item, index }: { item: any; index: number }) => ( + { + router.push( + `/admin/forum/${item?.Forum_Komentar?.id}/list-report-comment`, + ); + }} + > + + Pelapor} + value={ + + {item?.User?.username || "-"} + + } + /> + Komentar} + value={ + + {item?.Forum_Komentar?.komentar || "-"} + + } + /> + {item?.deskripsi ? + Deskripsi} + value={ + + {item?.deskripsi|| "-"} + + } + /> : Jenis Laporan} + value={ + + {item?.ForumMaster_KategoriReport?.title || "-"} + + } + /> + } + {/* Jenis Laporan} + value={ + + {item?.ForumMaster_KategoriReport?.title || "-"} + + } + /> */} + + + ), + [], + ); + + // Buat komponen-komponen pagination + const { ListEmptyComponent, ListFooterComponent } = + createPaginationComponents({ + loading: pagination.loading, + refreshing: pagination.refreshing, + listData: pagination.listData, + searchQuery: search, + emptyMessage: "Belum ada data report komentar", + emptySearchMessage: "Tidak ada hasil pencarian", + isInitialLoad: pagination.isInitialLoad, + skeletonCount: PAGINATION_DEFAULT_TAKE, + skeletonHeight: 100, + }); + + return ( + item.id?.toString() || `fallback-${item.id}`} + headerComponent={headerComponent} + ListEmptyComponent={ListEmptyComponent} + ListFooterComponent={ListFooterComponent} + onEndReached={pagination.loadMore} + refreshControl={ + + } + /> + ); +} diff --git a/screens/Admin/Forum/ScreenForumReportPosting.tsx b/screens/Admin/Forum/ScreenForumReportPosting.tsx new file mode 100644 index 0000000..00af6c7 --- /dev/null +++ b/screens/Admin/Forum/ScreenForumReportPosting.tsx @@ -0,0 +1,130 @@ +import { SearchInput, StackCustom, TextCustom } from "@/components"; +import AdminBasicBox from "@/components/_ShareComponent/Admin/AdminBasicBox"; +import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage"; +import { GridSpan_4_8 } from "@/components/_ShareComponent/GridSpan_4_8"; +import NewWrapper from "@/components/_ShareComponent/NewWrapper"; +import { MainColor } from "@/constants/color-palet"; +import { PAGINATION_DEFAULT_TAKE } from "@/constants/constans-value"; +import { createPaginationComponents } from "@/helpers/paginationHelpers"; +import { usePagination } from "@/hooks/use-pagination"; +import { apiAdminForum } from "@/service/api-admin/api-admin-forum"; +import { router } from "expo-router"; +import { useCallback, useMemo, useState } from "react"; +import { RefreshControl } from "react-native"; + +export function Admin_ScreenForumReportPosting() { + const [search, setSearch] = useState(""); + + // Gunakan hook pagination + const pagination = usePagination({ + fetchFunction: async (page, searchQuery) => { + const response = await apiAdminForum({ + category: "report_posting", + search: searchQuery || "", + page: String(page), + }); + + if (response.success) { + return { data: response.data }; + } else { + return { data: [] }; + } + }, + pageSize: PAGINATION_DEFAULT_TAKE, + searchQuery: search, + dependencies: [], + }); + + // Komponen search input + const searchComponent = useMemo( + () => ( + + ), + [search], + ); + + // Box title component + const headerComponent = useMemo( + () => ( + + ), + [searchComponent], + ); + + // Render item untuk daftar report posting + const renderItem = useCallback( + ({ item, index }: { item: any; index: number }) => ( + { + router.push( + `/admin/forum/${item?.Forum_Posting?.id}/list-report-posting`, + ); + }} + > + + Pelapor} + value={ + + {item?.User?.username || "-"} + + } + /> + Postingan} + value={ + + {item?.Forum_Posting?.diskusi || "-"} + + } + /> + + + ), + [], + ); + + // Buat komponen-komponen pagination + const { ListEmptyComponent, ListFooterComponent } = + createPaginationComponents({ + loading: pagination.loading, + refreshing: pagination.refreshing, + listData: pagination.listData, + searchQuery: search, + emptyMessage: "Belum ada data report posting", + emptySearchMessage: "Tidak ada hasil pencarian", + isInitialLoad: pagination.isInitialLoad, + skeletonCount: PAGINATION_DEFAULT_TAKE, + skeletonHeight: 100, + }); + + return ( + item.id?.toString() || `fallback-${item.id}`} + headerComponent={headerComponent} + ListEmptyComponent={ListEmptyComponent} + ListFooterComponent={ListFooterComponent} + onEndReached={pagination.loadMore} + refreshControl={ + + } + /> + ); +} diff --git a/service/api-admin/api-admin-forum.ts b/service/api-admin/api-admin-forum.ts index c48a134..3787513 100644 --- a/service/api-admin/api-admin-forum.ts +++ b/service/api-admin/api-admin-forum.ts @@ -3,13 +3,15 @@ import { apiConfig } from "../api-config"; export async function apiAdminForum({ category, search, + page = "1", }: { category: "dashboard" | "posting" | "report_posting" | "report_comment"; search?: string; + page?: string; }) { try { const response = await apiConfig.get( - `/mobile/admin/forum?category=${category}&search=${search}` + `/mobile/admin/forum?category=${category}&search=${search}&page=${page}` ); return response.data; } catch (error) { @@ -78,12 +80,14 @@ export async function apiAdminForumDeactivateComment({ export async function apiAdminForumListReportPostingById({ id, + page = "1", }: { id: string; + page?: string; }) { try { const response = await apiConfig.get( - `/mobile/admin/forum/${id}/report-posting` + `/mobile/admin/forum/${id}/report-posting?page=${page}` ); return response.data; } catch (error) {