(1);
const [isActivePage, setActivePage] = useState(1);
+ const [isSearch, setSearch] = useState("");
+ useShallowEffect(() => {
+ loadInitialData();
+ }, [isActivePage, isSearch])
- async function onPageClick(p: any) {
- setActivePage(p);
- const loadData = await adminEvent_getListPesertaById({
- eventId: eventId,
- page: p,
- });
- setData(loadData.data as any);
- setNPage(loadData.nPage);
+ const loadInitialData = async () => {
+ try {
+ const response = await apiGetAdminDetailEventPesertaById({
+ id: params.id,
+ page: `${isActivePage}`,
+ search: isSearch,
+ })
+
+ if (response?.success && response?.data.data) {
+ setData(response.data.data)
+ setNPage(response.data.nPage || 1)
+ } else {
+ console.error("Invalid data format recieved:", response);
+ setData([]);
+ }
+ } catch (error) {
+ clientLogger.error("Invalid data format recieved:", error);
+ setData([]);
+ }
}
- const tableRow = _.isEmpty(data)
- ? []
- : data.map((e, i) => (
+ const onSearch = async (searchTerm: string) => {
+ setSearch(searchTerm);
+ setActivePage(1);
+ }
+ const onPageClick = (page: number) => {
+ setActivePage(page);
+ }
+
+ const renderTableBody = () => {
+ if (!Array.isArray(data) || data.length === 0) {
+ return (
+
+ |
+
+ Tidak ada data
+
+ |
+
+ );
+ }
+
+ return data?.map((e, i) => (
|
{e?.User?.username}
@@ -67,65 +105,81 @@ export function AdminEvent_ViewDetailPeserta({
|
));
+ }
return (
<>
-
- Daftar Peserta
-
-
-
-
-
-
- |
- Username
- |
-
- Name
- |
-
- Nomor
- |
-
- Email
- |
-
- Konfirmasi Kehadiran
- |
-
-
- {tableRow}
-
- {_.isEmpty(data) ? (
-
- ) : (
- ""
- )}
-
-
-
- }
+ radius={"xl"}
+ placeholder="Masukan username"
onChange={(val) => {
- onPageClick(val);
+ onSearch(val.currentTarget.value);
}}
/>
-
-
+ }
+ />
+ {!data ? (
+
+ ): (
+
+
+
+
+
+ |
+ Username
+ |
+
+ Name
+ |
+
+ Nomor
+ |
+
+ Email
+ |
+
+ Konfirmasi Kehadiran
+ |
+
+
+ {renderTableBody()}
+
+ {_.isEmpty(data) ? (
+
+ ) : (
+ ""
+ )}
+
+
+
+ {
+ onPageClick(val);
+ }}
+ />
+
+
+ )}
+
{/* {JSON.stringify(dataPeserta, null, 2)} */}
>
diff --git a/src/app_modules/admin/event/table_status/detail_publish.tsx b/src/app_modules/admin/event/table_status/detail_publish.tsx
index 7b78bbe3..2fd2e3eb 100644
--- a/src/app_modules/admin/event/table_status/detail_publish.tsx
+++ b/src/app_modules/admin/event/table_status/detail_publish.tsx
@@ -53,7 +53,7 @@ function AdminEvent_DetailPublish() {
) : null}
{selectPage == "2" ? (
-
+
) : null}
{selectPage == "3" ? (
diff --git a/src/app_modules/admin/forum/lib/api_fetch_admin_forum.ts b/src/app_modules/admin/forum/lib/api_fetch_admin_forum.ts
index 0deb34a8..d611494e 100644
--- a/src/app_modules/admin/forum/lib/api_fetch_admin_forum.ts
+++ b/src/app_modules/admin/forum/lib/api_fetch_admin_forum.ts
@@ -1,10 +1,11 @@
export {
apiGetAdminForumPublishCountDasboard,
- apiGetAdminCountForumReportPosting ,
+ apiGetAdminCountForumReportPosting,
apiGetAdminCountForumReportKomentar,
apiGetAdminForumReportPosting,
apiGetAdminForumReportKomentar,
- apiGetAdminForumPublish
+ apiGetAdminForumPublish,
+ apiGetAdminHasilReportPosting
}
const apiGetAdminForumPublishCountDasboard = async () => {
@@ -38,7 +39,7 @@ const apiGetAdminCountForumReportPosting = async () => {
},
})
-
+
return await response.json().catch(() => null);
}
@@ -58,7 +59,7 @@ const apiGetAdminCountForumReportKomentar = async () => {
return await response.json().catch(() => null);
}
-const apiGetAdminForumReportPosting = async ({page} : { page?: string}) => {
+const apiGetAdminForumReportPosting = async ({ page }: { page?: string }) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
@@ -75,10 +76,10 @@ const apiGetAdminForumReportPosting = async ({page} : { page?: string}) => {
return await response.json().catch(() => null);
}
-const apiGetAdminForumReportKomentar = async({ page } : { page?: string}) => {
+const apiGetAdminForumReportKomentar = async ({ page }: { page?: string }) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
-
+
const isPage = page ? `?page=${page}` : "";
const response = await fetch(`/api/admin/forum/komentar${isPage}`, {
method: "GET",
@@ -92,12 +93,13 @@ const apiGetAdminForumReportKomentar = async({ page } : { page?: string}) => {
return await response.json().catch(() => null);
}
-const apiGetAdminForumPublish = async ({ page }: { page?: string }) => {
+const apiGetAdminForumPublish = async (
+ { page }: { page?: string }) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
const isPage = page ? `?page=${page}` : "";
- const response = await fetch(`/api/admin/forum/publish${isPage}`, {
+ const response = await fetch(`/api/admin/forum/publish/${isPage}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
@@ -106,15 +108,26 @@ const apiGetAdminForumPublish = async ({ page }: { page?: string }) => {
Authorization: `Bearer ${token}`,
},
})
-
+
return await response.json().catch(() => null);
}
-const apiGetAdminHasilReportPosting = async ({id} : {id: string}) => {
+const apiGetAdminHasilReportPosting = async ({ page, id }: { page?: string, id: string }) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
-
+ const isPage = page ? `?page=${page}` : "";
+ const response = await fetch(`/api/admin/forum/${id}/report_posting${isPage}`, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json",
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`,
+ }
+ })
+
+ return await response.json().catch(() => null);
}
\ No newline at end of file
diff --git a/src/middleware.ts b/src/middleware.ts
index cab61889..22fc62e5 100644
--- a/src/middleware.ts
+++ b/src/middleware.ts
@@ -34,10 +34,8 @@ const middlewareConfig: MiddlewareConfig = {
// ADMIN API
// >> buat dibawah sini <<
- // "/api/admin/collaboration/*",
- // "/api/admin/investasi/*",
- // "/api/admin/event/*",
- // "/api/admin/forum/*",
+
+
// Akses awal
"/api/get-cookie",