From 32a42d1b60bff01e4e453ee8db94e43211638ab1 Mon Sep 17 00:00:00 2001 From: bagasbanuna Date: Fri, 20 Feb 2026 16:48:26 +0800 Subject: [PATCH] Fix UI Admin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User & Image - app/(application)/(image)/take-picture/[id]/index.tsx - app/(application)/(user)/home.tsx Admin – Forum - app/(application)/admin/forum/[id]/index.tsx - app/(application)/admin/forum/[id]/list-comment.tsx - app/(application)/admin/forum/[id]/list-report-comment.tsx Admin Screens – Forum - screens/Admin/Forum/ScreenForumDetailReportPosting.tsx - screens/Admin/Forum/ScreenForumReportComment.tsx - screens/Admin/Forum/ScreenForumReportPosting.tsx New Admin Screens – Forum - screens/Admin/Forum/ScreenForumDetailReportComment.tsx - screens/Admin/Forum/ScreenForumListComment.tsx Home - screens/Home/bottomFeatureSection.tsx Service - service/api-admin/api-admin-forum.ts Docs - docs/prompt-for-qwen-code.md ### No Issue --- .../(image)/take-picture/[id]/index.tsx | 2 +- app/(application)/(user)/home.tsx | 17 +- app/(application)/admin/forum/[id]/index.tsx | 13 +- .../admin/forum/[id]/list-comment.tsx | 90 +----- .../admin/forum/[id]/list-report-comment.tsx | 261 +--------------- docs/prompt-for-qwen-code.md | 10 +- .../Forum/ScreenForumDetailReportComment.tsx | 292 ++++++++++++++++++ .../Forum/ScreenForumDetailReportPosting.tsx | 180 +++++------ .../Admin/Forum/ScreenForumListComment.tsx | 105 +++++++ .../Admin/Forum/ScreenForumReportComment.tsx | 68 ++-- .../Admin/Forum/ScreenForumReportPosting.tsx | 29 +- screens/Home/bottomFeatureSection.tsx | 5 + service/api-admin/api-admin-forum.ts | 8 +- 13 files changed, 547 insertions(+), 533 deletions(-) create mode 100644 screens/Admin/Forum/ScreenForumDetailReportComment.tsx create mode 100644 screens/Admin/Forum/ScreenForumListComment.tsx diff --git a/app/(application)/(image)/take-picture/[id]/index.tsx b/app/(application)/(image)/take-picture/[id]/index.tsx index fd56052..42e22cb 100644 --- a/app/(application)/(image)/take-picture/[id]/index.tsx +++ b/app/(application)/(image)/take-picture/[id]/index.tsx @@ -105,7 +105,7 @@ export default function TakePicture() { - + diff --git a/app/(application)/(user)/home.tsx b/app/(application)/(user)/home.tsx index 38dc8a2..c0a1987 100644 --- a/app/(application)/(user)/home.tsx +++ b/app/(application)/(user)/home.tsx @@ -77,14 +77,14 @@ export default function Application() { ); } - if (data && data?.masterUserRoleId !== "1") { - console.log("User is not admin"); - return ( - - - - ); - } + // if (data && data?.masterUserRoleId !== "1") { + // console.log("User is not admin"); + // return ( + // + // + // + // ); + // } return ( <> @@ -115,6 +115,7 @@ export default function Application() { } footerComponent={ { onLoadData(); - }, [id]) + }, [id]), ); const onLoadData = async () => { @@ -72,6 +72,10 @@ export default function AdminForumDetailPosting() { label: "Total Report", value: data?.JumlahReportPosting || 0, }, + { + label: "Postingan", + value: (data && data?.diskusi) || "-", + }, ]; return ( @@ -111,13 +115,6 @@ export default function AdminForumDetailPosting() { ))} - - - - Postingan - {(data && data?.diskusi) || "-"} - - (null); - const [loadList, setLoadList] = useState(false); - - useFocusEffect( - useCallback(() => { - onLoadComment(); - }, [id]) - ); - - const onLoadComment = async () => { - try { - setLoadList(true); - const response = await apiAdminForumCommentById({ - id: id as string, - category: "get-all", - }); - - if (response.success) { - setListComment(response.data); - } - } catch (error) { - console.log("[ERROR]", error); - setListComment([]); - } finally { - setLoadList(false); - } - }; - - return ( - <> - } - > - - - - {loadList ? ( - - ) : _.isEmpty(listComment) ? ( - - Tidak ada komentar - - ) : ( - listComment?.map((item: any, index: number) => ( - { - router.push( - `/admin/forum/${item.id}/list-report-comment` - ); - }} - /> - } - value2={ - - {item?.countReport || 0} - - } - value3={ - {item?.komentar || "-"} - } - /> - )) - )} - - - - - ); + return ; } diff --git a/app/(application)/admin/forum/[id]/list-report-comment.tsx b/app/(application)/admin/forum/[id]/list-report-comment.tsx index a5915fe..62fe4bd 100644 --- a/app/(application)/admin/forum/[id]/list-report-comment.tsx +++ b/app/(application)/admin/forum/[id]/list-report-comment.tsx @@ -1,262 +1,5 @@ -/* eslint-disable react-hooks/exhaustive-deps */ -import { - ActionIcon, - AlertDefaultSystem, - 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 { - apiAdminForumCommentById, - apiAdminForumDeactivateComment, - apiAdminForumListReportCommentById, -} 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_ScreenForumDetailReportComment } from "@/screens/Admin/Forum/ScreenForumDetailReportComment"; export default function AdminForumReportComment() { - const { id } = useLocalSearchParams(); - const { user } = useAuth(); - const [data, setData] = useState(null); - const [listReport, setListReport] = useState(null); - const [loadList, setLoadList] = useState(false); - const [openDrawer, setOpenDrawer] = useState(false); - const [openDrawerAction, setOpenDrawerAction] = useState(false); - const [selectedReport, setSelectedReport] = useState({ - id: "", - username: "", - kategori: "", - keterangan: "", - deskripsi: "", - }); - - useFocusEffect( - useCallback(() => { - onLoadData(); - }, [id]) - ); - - const onLoadData = async () => { - try { - setLoadList(true); - const response = await apiAdminForumCommentById({ - id: id as string, - category: "get-one", - }); - - const responseReport = await apiAdminForumListReportCommentById({ - id: id as string, - }); - - if (response.success) { - setData(response.data); - } - if (responseReport.success) { - setListReport(responseReport.data); - } - } catch (error) { - console.log("[ERROR]", error); - setData(null); - setListReport([]); - } finally { - setLoadList(false); - } - }; - - return ( - <> - } - onPress={() => setOpenDrawer(true)} - /> - } - /> - } - > - - - Username} - text2={{data?.Author?.username || "-"}} - /> - Komentar} - text2={{data?.komentar || "-"}} - /> - - - - - - - - Aksi - - } - text2={Pelapor} - text3={Kategori Report} - /> - - {loadList ? ( - - ) : _.isEmpty(listReport) ? ( - - Tidak 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 || "-"} - - } - /> - - - )) - )} - - - - setOpenDrawer(false)} - height={"auto"} - > - , - label: "Hapus Komentar", - value: "delete", - path: "", - color: MainColor.red, - }, - ]} - onPressItem={(item) => { - AlertDefaultSystem({ - title: "Hapus Komentar", - message: "Apakah Anda yakin ingin menghapus komentar ini?", - textLeft: "Batal", - textRight: "Hapus", - onPressRight: async () => { - const deleteComment = await apiAdminForumDeactivateComment({ - id: id as string, - data: { - senderId: user?.id as string, - }, - }); - - // if (!deleteComment.success) { - // Toast.show({ - // type: "error", - // text1: "Komentar gagal dihapus", - // }); - // return; - // } - - setOpenDrawer(false); - Toast.show({ - type: "success", - text1: "Komentar 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 || "-"} - } - /> - )} - - - - ); + return ; } diff --git a/docs/prompt-for-qwen-code.md b/docs/prompt-for-qwen-code.md index d640487..1f24be0 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/forum/[id]/list-report-posting.tsx +File source: app/(application)/admin/forum/[id]/list-comment.tsx Folder tujuan: screens/Admin/Forum -Nama file utama: ScreenForumDetailReportPosting.tsx -Nama function utama: Admin_ScreenForumDetailReportPosting +Nama file utama: ScreenForumListComment.tsx +Nama function utama: Admin_ScreenForumListComment 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,7 +66,7 @@ Analisa juga file "Nama file utama" , jika belum menggunakan NewWrapper pada fil -Function fecth: apiAdminForumListReportPostingById +Function fecth: apiAdminForumCommentById File function fetch: service/api-admin/api-admin-forum.ts Terapkan pagination pada file "Nama file utama" @@ -80,7 +80,7 @@ Gunakan bahasa indonesia pada cli agar saya mudah membacanya. -File refrensi: screens/Admin/Forum/ScreenForumReportPosting.tsx +File refrensi: screens/Admin/Forum/ScreenForumDetailReportPosting.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 diff --git a/screens/Admin/Forum/ScreenForumDetailReportComment.tsx b/screens/Admin/Forum/ScreenForumDetailReportComment.tsx new file mode 100644 index 0000000..0f4b19e --- /dev/null +++ b/screens/Admin/Forum/ScreenForumDetailReportComment.tsx @@ -0,0 +1,292 @@ +/* eslint-disable react-hooks/exhaustive-deps */ +import { + ActionIcon, + AlertDefaultSystem, + DrawerCustom, + MenuDrawerDynamicGrid, + StackCustom, + TextCustom, +} from "@/components"; +import { IconDot } from "@/components/_Icon/IconComponent"; +import { IconTrash } from "@/components/_Icon/IconTrash"; +import AdminBasicBox from "@/components/_ShareComponent/Admin/AdminBasicBox"; +import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle"; +import { GridSpan_4_8 } from "@/components/_ShareComponent/GridSpan_4_8"; +import GridTwoView from "@/components/_ShareComponent/GridTwoView"; +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 { useAuth } from "@/hooks/use-auth"; +import { usePagination } from "@/hooks/use-pagination"; +import { + apiAdminForumCommentById, + apiAdminForumDeactivateComment, + apiAdminForumListReportCommentById, +} from "@/service/api-admin/api-admin-forum"; +import { router, useFocusEffect, useLocalSearchParams } from "expo-router"; +import { useCallback, useMemo, useState } from "react"; +import { RefreshControl } from "react-native"; +import Toast from "react-native-toast-message"; + +export function Admin_ScreenForumDetailReportComment() { + 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 komentar saat screen fokus + useFocusEffect( + useCallback(() => { + onLoadDataKomentar(); + }, [id]), + ); + + // Pagination untuk list report comment + const pagination = usePagination({ + fetchFunction: async (page) => { + const response = await apiAdminForumListReportCommentById({ + id: id as string, + page: String(page), + }); + + if (response.success) { + return { data: response.data }; + } + return { data: [] }; + }, + pageSize: PAGINATION_DEFAULT_TAKE, + dependencies: [id], + }); + + const onLoadDataKomentar = async () => { + try { + const response = await apiAdminForumCommentById({ + id: id as string, + category: "get-one", + }); + + if (response.success) { + setData(response.data); + } + } catch (error) { + console.log("[ERROR]", error); + } + }; + + // Render item untuk daftar report comment + const renderItem = useCallback( + ({ item, index }: { item: any; index: number }) => ( + { + setOpenDrawerAction(true); + setSelectedReport({ + id: item?.id, + username: item?.User?.username, + kategori: item?.ForumMaster_KategoriReport?.title, + keterangan: item?.ForumMaster_KategoriReport?.deskripsi, + deskripsi: item?.deskripsi, + }); + }} + > + + Pelapor} + rightItem={ + + {item?.User?.username || "-"} + + } + /> + Jenis Laporan} + rightItem={ + + {item + ? item?.ForumMaster_KategoriReport?.title + ? item?.ForumMaster_KategoriReport?.title + : "Lainnya" + : "-"} + + } + /> + + + ), + [], + ); + + // Header component dengan back button dan menu + const headerComponent = useMemo( + () => ( + } + onPress={() => setOpenDrawerPage(true)} + /> + } + /> + ), + [], + ); + + // Detail komentar component + const ListHeader = useMemo( + () => ( + + + Username} + value={{data?.Author?.username || "-"}} + /> + Komentar} + value={{data?.komentar || "-"}} + /> + + + ), + [data], + ); + + // Buat komponen-komponen pagination + const { ListEmptyComponent, ListFooterComponent } = + createPaginationComponents({ + loading: pagination.loading, + refreshing: pagination.refreshing, + listData: pagination.listData, + emptyMessage: "Belum ada report komentar", + emptySearchMessage: "Tidak ada hasil pencarian", + isInitialLoad: pagination.isInitialLoad, + skeletonCount: PAGINATION_DEFAULT_TAKE, + skeletonHeight: 100, + }); + + return ( + <> + + } + /> + + {/* Drawer untuk menu halaman (hapus komentar) */} + setOpenDrawerPage(false)} + height={"auto"} + > + , + label: "Hapus Komentar", + value: "delete", + path: "", + color: MainColor.red, + }, + ]} + onPressItem={(item) => { + AlertDefaultSystem({ + title: "Hapus Komentar", + message: "Apakah Anda yakin ingin menghapus komentar ini?", + textLeft: "Batal", + textRight: "Hapus", + onPressRight: async () => { + const response = await apiAdminForumDeactivateComment({ + id: id as string, + data: { + senderId: user?.id as string, + }, + }); + + if (!response.success) { + Toast.show({ + type: "error", + text1: "Komentar gagal dihapus", + }); + return; + } + + setOpenDrawerPage(false); + Toast.show({ + type: "success", + text1: "Komentar berhasil dihapus", + }); + router.back(); + }, + }); + }} + /> + + + {/* Drawer untuk detail report comment */} + 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/ScreenForumDetailReportPosting.tsx b/screens/Admin/Forum/ScreenForumDetailReportPosting.tsx index b254ffd..725b437 100644 --- a/screens/Admin/Forum/ScreenForumDetailReportPosting.tsx +++ b/screens/Admin/Forum/ScreenForumDetailReportPosting.tsx @@ -2,39 +2,31 @@ import { ActionIcon, AlertDefaultSystem, - BadgeCustom, - BaseBox, - CenterCustom, DrawerCustom, MenuDrawerDynamicGrid, StackCustom, TextCustom, } from "@/components"; -import { IconDot, IconView } from "@/components/_Icon/IconComponent"; +import { IconDot } from "@/components/_Icon/IconComponent"; import { IconTrash } from "@/components/_Icon/IconTrash"; +import AdminBasicBox from "@/components/_ShareComponent/Admin/AdminBasicBox"; 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 GridTwoView from "@/components/_ShareComponent/GridTwoView"; import NewWrapper from "@/components/_ShareComponent/NewWrapper"; import { MainColor } from "@/constants/color-palet"; -import { - ICON_SIZE_BUTTON, - PAGINATION_DEFAULT_TAKE, -} from "@/constants/constans-value"; +import { 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 { usePagination } from "@/hooks/use-pagination"; 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 { RefreshControl } from "react-native"; import Toast from "react-native-toast-message"; export function Admin_ScreenForumDetailReportPosting() { @@ -55,12 +47,12 @@ export function Admin_ScreenForumDetailReportPosting() { useFocusEffect( useCallback(() => { onLoadDataPosting(); - }, [id]) + }, [id]), ); // Pagination untuk list report const pagination = usePagination({ - fetchFunction: async (page, searchQuery) => { + fetchFunction: async (page) => { const response = await apiAdminForumListReportPostingById({ id: id as string, page: String(page), @@ -91,41 +83,50 @@ export function Admin_ScreenForumDetailReportPosting() { // 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 || "-"} - - } - /> - - + ({ item, index }: { item: any; index: number }) => ( + { + setOpenDrawerAction(true); + setSelectedReport({ + id: item?.id, + username: item?.User?.username, + kategori: item?.ForumMaster_KategoriReport?.title, + keterangan: item?.ForumMaster_KategoriReport?.deskripsi, + deskripsi: item?.deskripsi, + }); + }} + > + + Pelapor} + rightItem={ + + {item?.User?.username || "-"} + + } + /> + Jenis Laporan} + rightItem={ + + {item + ? item?.ForumMaster_KategoriReport?.title + ? item?.ForumMaster_KategoriReport?.title + : "Lainnya" + : "-"} + + } + /> + + ), - [] + [], ); // Header component dengan detail postingan @@ -141,75 +142,33 @@ export function Admin_ScreenForumDetailReportPosting() { } /> ), - [] + [], ); // Detail postingan component - const postingDetailComponent = useMemo( + const ListHeader = useMemo( () => ( - - - Username} - text2={{data?.Author?.username || "-"}} - /> - - Status} - text2={ - data && data?.ForumMaster_StatusPosting?.status ? ( - - {data?.ForumMaster_StatusPosting?.status === "Open" - ? "Open" - : "Close"} - - ) : ( - {"-"} - ) + + + Username} + rightItem={ + {data ? data?.Author?.username : "-"} } /> - Postingan} - text2={{data?.diskusi || "-"}} + Postingan} + rightItem={{data ? 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] + [data], ); // Buat komponen-komponen pagination @@ -231,7 +190,7 @@ export function Admin_ScreenForumDetailReportPosting() { listData={pagination.listData} renderItem={renderItem} headerComponent={headerComponent} - ListHeaderComponent={reportListHeaderComponent} + ListHeaderComponent={ListHeader} ListEmptyComponent={ListEmptyComponent} ListFooterComponent={ListFooterComponent} onEndReached={pagination.loadMore} @@ -295,7 +254,6 @@ export function Admin_ScreenForumDetailReportPosting() { /> - {/* Drawer untuk detail report */} setOpenDrawerAction(false)} diff --git a/screens/Admin/Forum/ScreenForumListComment.tsx b/screens/Admin/Forum/ScreenForumListComment.tsx new file mode 100644 index 0000000..fa8b88b --- /dev/null +++ b/screens/Admin/Forum/ScreenForumListComment.tsx @@ -0,0 +1,105 @@ +/* eslint-disable react-hooks/exhaustive-deps */ +import { StackCustom, TextCustom } from "@/components"; +import AdminBasicBox from "@/components/_ShareComponent/Admin/AdminBasicBox"; +import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle"; +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 { useAuth } from "@/hooks/use-auth"; +import { usePagination } from "@/hooks/use-pagination"; +import { apiAdminForumCommentById } from "@/service/api-admin/api-admin-forum"; +import { router, useLocalSearchParams } from "expo-router"; +import { useCallback, useMemo, useState } from "react"; +import { RefreshControl } from "react-native"; +import { Divider } from "react-native-paper"; + +export function Admin_ScreenForumListComment() { + const { user } = useAuth(); + const { id } = useLocalSearchParams(); + const [openDrawerAction, setOpenDrawerAction] = useState(false); + const [selectedComment, setSelectedComment] = useState({ + id: "", + komentar: "", + }); + + // Pagination untuk list comment + const pagination = usePagination({ + fetchFunction: async (page) => { + const response = await apiAdminForumCommentById({ + id: id as string, + category: "get-all", + page: String(page), + }); + + if (response.success) { + return { data: response.data }; + } + return { data: [] }; + }, + pageSize: PAGINATION_DEFAULT_TAKE, + dependencies: [id], + }); + + // Render item untuk daftar komentar + const renderItem = useCallback( + ({ item, index }: { item: any; index: number }) => ( + { + router.push(`/admin/forum/${item.id}/list-report-comment`); + }} + > + + + Report : {item?.countReport || 0} + + + {item?.komentar || "-"} + + + ), + [], + ); + + // Header component dengan back button + const headerComponent = useMemo( + () => , + [], + ); + + // Buat komponen-komponen pagination + const { ListEmptyComponent, ListFooterComponent } = + createPaginationComponents({ + loading: pagination.loading, + refreshing: pagination.refreshing, + listData: pagination.listData, + emptyMessage: "Belum ada komentar", + emptySearchMessage: "Tidak ada hasil pencarian", + isInitialLoad: pagination.isInitialLoad, + skeletonCount: PAGINATION_DEFAULT_TAKE, + skeletonHeight: 100, + }); + + return ( + <> + + } + /> + + ); +} diff --git a/screens/Admin/Forum/ScreenForumReportComment.tsx b/screens/Admin/Forum/ScreenForumReportComment.tsx index f306a77..437833c 100644 --- a/screens/Admin/Forum/ScreenForumReportComment.tsx +++ b/screens/Admin/Forum/ScreenForumReportComment.tsx @@ -1,16 +1,15 @@ 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 GridTwoView from "@/components/_ShareComponent/GridTwoView"; 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 { router, useFocusEffect } 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(""); @@ -25,7 +24,6 @@ export function Admin_ScreenForumReportComment() { }); if (response.success) { - console.log("CEK", JSON.stringify(response.data, null, 2)); return { data: response.data }; } else { return { data: [] }; @@ -36,6 +34,12 @@ export function Admin_ScreenForumReportComment() { dependencies: [], }); + useFocusEffect( + useCallback(() => { + pagination.onRefresh(); + }, []), + ); + // Komponen search input const searchComponent = useMemo( () => ( @@ -73,47 +77,27 @@ export function Admin_ScreenForumReportComment() { }} > - Pelapor} - value={ - - {item?.User?.username || "-"} + Jumlah Report} + rightItem={ + + {item?.count || "-"} } /> - 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 || "-"} - - } - /> */} + + Komentar} + rightItem={ + + {item?.Forum_Komentar?.komentar || "-"} + + } + /> ), diff --git a/screens/Admin/Forum/ScreenForumReportPosting.tsx b/screens/Admin/Forum/ScreenForumReportPosting.tsx index 00af6c7..b891919 100644 --- a/screens/Admin/Forum/ScreenForumReportPosting.tsx +++ b/screens/Admin/Forum/ScreenForumReportPosting.tsx @@ -1,14 +1,14 @@ 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 GridTwoView from "@/components/_ShareComponent/GridTwoView"; 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 { router, useFocusEffect } from "expo-router"; import { useCallback, useMemo, useState } from "react"; import { RefreshControl } from "react-native"; @@ -25,6 +25,7 @@ export function Admin_ScreenForumReportPosting() { }); if (response.success) { + return { data: response.data }; } else { return { data: [] }; @@ -35,6 +36,12 @@ export function Admin_ScreenForumReportPosting() { dependencies: [], }); + useFocusEffect( + useCallback(() => { + pagination.onRefresh(); + }, []), + ); + // Komponen search input const searchComponent = useMemo( () => ( @@ -72,17 +79,21 @@ export function Admin_ScreenForumReportPosting() { }} > - Pelapor} - value={ + Jumlah Report} + rightItem={ - {item?.User?.username || "-"} + {item?.count|| "-"} } /> - Postingan} - value={ + Postingan} + rightItem={ {item?.Forum_Posting?.diskusi || "-"} diff --git a/screens/Home/bottomFeatureSection.tsx b/screens/Home/bottomFeatureSection.tsx index d01e602..9e56f64 100644 --- a/screens/Home/bottomFeatureSection.tsx +++ b/screens/Home/bottomFeatureSection.tsx @@ -6,6 +6,7 @@ import Icon from "react-native-vector-icons/FontAwesome"; import { stylesHome } from "./homeViewStyle"; import { router, useFocusEffect } from "expo-router"; import { apiJobGetAll } from "@/service/api-client/api-job"; +import CustomSkeleton from "@/components/_ShareComponent/SkeletonCustom"; export default function Home_BottomFeatureSection() { const [listData, setListData] = useState([]); @@ -35,6 +36,10 @@ export default function Home_BottomFeatureSection() { }, []) ); + if (!listData || listData.length === 0) { + return + } + return ( <> router.push("/job")}> diff --git a/service/api-admin/api-admin-forum.ts b/service/api-admin/api-admin-forum.ts index 3787513..397a081 100644 --- a/service/api-admin/api-admin-forum.ts +++ b/service/api-admin/api-admin-forum.ts @@ -30,13 +30,15 @@ export async function apiAdminForumPostingById({ id }: { id: string }) { export async function apiAdminForumCommentById({ id, category, + page = "1", }: { id: string; category: "get-all" | "get-one"; + page?: string; }) { try { const response = await apiConfig.get( - `/mobile/admin/forum/${id}/comment?category=${category}` + `/mobile/admin/forum/${id}/comment?category=${category}&page=${page}` ); return response.data; } catch (error) { @@ -46,12 +48,14 @@ export async function apiAdminForumCommentById({ export async function apiAdminForumListReportCommentById({ id, + page = "1", }: { id: string; + page?: string; }) { try { const response = await apiConfig.get( - `/mobile/admin/forum/${id}/report-comment` + `/mobile/admin/forum/${id}/report-comment?page=${page}` ); return response.data; } catch (error) {