From 5f36620988f6e1151fdc8905d29daad36ed0a30e Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Tue, 14 Oct 2025 17:28:40 +0800 Subject: [PATCH] Integrasi Admin: User Acces & Super Admin Add: - admin/super-admin/ - admin/user-access/ - service/api-admin/ Fix: - (user)/profile/[id]/index: penambahan useData dari useAuthuntuk merestart value masterRole - integrasi pada tampilan admin ### No Issue --- .../(user)/profile/[id]/index.tsx | 8 +- app/(application)/(user)/waiting-room.tsx | 24 ++- app/(application)/admin/_layout.tsx | 60 ++++--- app/(application)/admin/dashboard.tsx | 36 +++-- .../admin/super-admin/[id]/index.tsx | 128 +++++++++++++++ app/(application)/admin/super-admin/index.tsx | 148 ++++++++++++++++++ app/(application)/admin/user-access.tsx | 117 -------------- .../admin/user-access/[id]/index.tsx | 124 +++++++++++++++ app/(application)/admin/user-access/index.tsx | 143 +++++++++++++++++ components/ActionIcon/ActionIcon.tsx | 8 +- components/_ShareComponent/GridTwoView.tsx | 18 ++- .../_ShareComponent/GridViewCustomSpan.tsx | 34 +++- context/AuthContext.tsx | 2 +- screens/Admin/listPageAdmin.tsx | 100 +++++++++++- service/api-admin/api-admin-main-dashboard.ts | 10 ++ service/api-admin/api-admin-user-access.ts | 47 ++++++ 16 files changed, 833 insertions(+), 174 deletions(-) create mode 100644 app/(application)/admin/super-admin/[id]/index.tsx create mode 100644 app/(application)/admin/super-admin/index.tsx delete mode 100644 app/(application)/admin/user-access.tsx create mode 100644 app/(application)/admin/user-access/[id]/index.tsx create mode 100644 app/(application)/admin/user-access/index.tsx create mode 100644 service/api-admin/api-admin-main-dashboard.ts create mode 100644 service/api-admin/api-admin-user-access.ts diff --git a/app/(application)/(user)/profile/[id]/index.tsx b/app/(application)/(user)/profile/[id]/index.tsx index 3d50901..d4a55ca 100644 --- a/app/(application)/(user)/profile/[id]/index.tsx +++ b/app/(application)/(user)/profile/[id]/index.tsx @@ -26,7 +26,7 @@ export default function Profile() { const [dataToken, setDataToken] = useState(); const [listPortofolio, setListPortofolio] = useState(); - const { logout, isAdmin, user } = useAuth(); + const { token, logout, isAdmin, user, userData } = useAuth(); const openDrawer = () => { setIsDrawerOpen(true); @@ -42,7 +42,8 @@ export default function Profile() { onLoadPortofolio(id as string); onLoadUserByToken(); isUserCheck(); - }, [id]) + userData(token as string); + }, [id, token]) ); const isUserCheck = () => { @@ -136,10 +137,7 @@ const ButtonnDot = ({ }) => { const isId = id === undefined || id === null; - console.log("ID CHECK", id); - if (isId) { - console.log("ID UNDEFINED", id); return ( <> diff --git a/app/(application)/(user)/waiting-room.tsx b/app/(application)/(user)/waiting-room.tsx index f9e126e..3d2cf16 100644 --- a/app/(application)/(user)/waiting-room.tsx +++ b/app/(application)/(user)/waiting-room.tsx @@ -9,6 +9,7 @@ import { } from "@/components"; import { ICON_SIZE_BUTTON } from "@/constants/constans-value"; import { useAuth } from "@/hooks/use-auth"; +import { apiUser } from "@/service/api-client/api-user"; import { Ionicons } from "@expo/vector-icons"; import { router } from "expo-router"; import Toast from "react-native-toast-message"; @@ -19,12 +20,25 @@ export default function WaitingRoom() { async function handleCheck() { try { const response = await userData(token as string); + if (response.active) { - Toast.show({ - type: "success", - text1: "Akun anda telah aktif", // text2: "Anda berhasil login", - }); - router.replace(`/(application)/(user)/profile/create`); + const checkProfile = await apiUser(response.id); + + if (checkProfile?.data?.Profile) { + Toast.show({ + type: "success", + text1: "Akun anda telah aktif kembali", // text2: "Anda berhasil login", + }); + router.replace(`/(application)/(user)/home`); + } else { + Toast.show({ + type: "success", + text1: "Akun anda telah aktif", // text2: "Anda berhasil login", + }); + router.replace(`/(application)/(user)/profile/create`); + } + + // router.replace(`/(application)/(user)/profile/create`); } else { Toast.show({ type: "error", diff --git a/app/(application)/admin/_layout.tsx b/app/(application)/admin/_layout.tsx index 282eb4c..c1f91d1 100644 --- a/app/(application)/admin/_layout.tsx +++ b/app/(application)/admin/_layout.tsx @@ -15,7 +15,10 @@ import { ICON_SIZE_XLARGE, } from "@/constants/constans-value"; import { useAuth } from "@/hooks/use-auth"; -import { adminListMenu } from "@/screens/Admin/listPageAdmin"; +import { + adminListMenu, + superAdminListMenu, +} from "@/screens/Admin/listPageAdmin"; import { GStyles } from "@/styles/global-styles"; import { FontAwesome6, Ionicons } from "@expo/vector-icons"; import { router, Stack } from "expo-router"; @@ -24,8 +27,11 @@ import { useState } from "react"; export default function AdminLayout() { const [openDrawerNavbar, setOpenDrawerNavbar] = useState(false); const [openDrawerUser, setOpenDrawerUser] = useState(false); + // const [user, setUser] = useState(null); - const { logout } = useAuth(); + const { logout, user } = useAuth(); + + console.log("[USER LAYOUT]", JSON.stringify(user, null, 2)); return ( <> @@ -56,58 +62,58 @@ export default function AdminLayout() { ), }} > - + {/* */} {/* ================== Investment Start ================== */} - + {/* */} {/* ================== Investment End ================== */} {/* ================== Maps Start ================== */} - + {/* */} {/* ================== Maps End ================== */} {/* ================== App Information Start ================== */} - + {/* */} {/* ================== App Information End ================== */} {/* ================== Job Start ================== */} - + {/* */} {/* */} - - + {/* + */} {/* ================== Collaboration Start ================== */} - - + {/* */} + {/* - + */} {/* ================== Collaboration End ================== */} {/* ================== Forum Start ================== */} - - + {/* */} + {/* - + */} {/* ================== Forum End ================== */} {/* ================== Voting Start ================== */} - + {/* - + */} {/* ================== Voting End ================== */} {/* ================== Event Start ================== */} - + {/* - + */} {/* */} {/* ================== Event End ================== */} @@ -134,7 +140,11 @@ export default function AdminLayout() { /> setOpenDrawerNavbar(false)} /> @@ -155,7 +165,7 @@ export default function AdminLayout() { /> } > - Username + {user?.username || "-"} } > - User Role + + {user + ? user?.masterUserRoleId === "2" + ? "Admin" + : "Super Admin" + : "-"} + { + onLoadData(); + }, []); + + const onLoadData = async () => { + try { + const response = await apiAdminMainDashboardGetAll(); + + if (response.success) { + setCountUser(response.data.user); + setCountPortofolio(response.data.portofolio); + } + } catch (error) { + console.log("[ERROR LOAD DATA]", error); + } + }; + return ( <> @@ -15,7 +33,7 @@ export default function AdminDashboard() { Main Dashboard - {listData.map((item, i) => ( + {listData(countUser, countPortofolio).map((item, i) => ( ))} @@ -24,15 +42,15 @@ export default function AdminDashboard() { ); } -const listData = [ +const listData = (countUser: number, countPortofolio: number) => [ { label: "User", - value: 4, + value: countUser, icon: , }, { label: "Portofolio", - value: 7, + value: countPortofolio, icon: ( ), diff --git a/app/(application)/admin/super-admin/[id]/index.tsx b/app/(application)/admin/super-admin/[id]/index.tsx new file mode 100644 index 0000000..4e791c3 --- /dev/null +++ b/app/(application)/admin/super-admin/[id]/index.tsx @@ -0,0 +1,128 @@ +/* eslint-disable react-hooks/exhaustive-deps */ +import { + BoxButtonOnFooter, + ButtonCustom, + LoaderCustom, + StackCustom, + TextCustom, + ViewWrapper, +} from "@/components"; +import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle"; +import GridTwoView from "@/components/_ShareComponent/GridTwoView"; +import { + apiAdminUserAccessGetById, + apiAdminUserAccessUpdateStatus, +} from "@/service/api-admin/api-admin-user-access"; +import { router, useFocusEffect, useLocalSearchParams } from "expo-router"; +import { useCallback, useState } from "react"; +import Toast from "react-native-toast-message"; + +export default function SuperAdminDetail() { + const { id } = useLocalSearchParams(); + const [data, setData] = useState(null); + const [loadData, setLoadData] = useState(false); + const [isLoading, setLoading] = useState(false); + + useFocusEffect( + useCallback(() => { + onLoadData(); + }, [id]) + ); + + const onLoadData = async () => { + try { + setLoadData(true); + const response = await apiAdminUserAccessGetById({ id: id as string }); + + setData(response.data); + } catch (error) { + console.log("[ERROR LOAD DATA]", error); + } finally { + setLoadData(false); + } + }; + + const handlerSubmit = async () => { + try { + setLoading(true); + const response = await apiAdminUserAccessUpdateStatus({ + id: id as string, + role: data?.masterUserRoleId === "2" ? "user" : "admin", + }); + + if (!response.success) { + Toast.show({ + type: "error", + text1: "Update role gagal", + }); + return; + } + Toast.show({ + type: "success", + text1: "Update role berhasil ", + }); + router.back(); + } catch (error) { + console.log("[ERROR UPDATE STATUS]", error); + } finally { + setLoading(false); + } + }; + + return ( + <> + } + footerComponent={ + data && ( + + + {data?.masterUserRoleId === "2" + ? "Hapus akses admin" + : "Tambah sebagai admin"} + + + ) + } + > + {loadData ? ( + + ) : ( + + {listData(data && data)?.map((item: any, index: number) => ( + {item?.label}} + rightIcon={{item?.value}} + /> + ))} + + )} + + + ); +} + +const listData = (data: any) => [ + { + label: "Username", + value: (data && data?.username) || "-", + }, + { + label: "Role", + value: data && data?.masterUserRoleId === "2" ? "Admin" : "User", + }, + { + label: "Nomor", + value: (data && `+${data?.nomor}`) || "-", + }, +]; diff --git a/app/(application)/admin/super-admin/index.tsx b/app/(application)/admin/super-admin/index.tsx new file mode 100644 index 0000000..bea4a71 --- /dev/null +++ b/app/(application)/admin/super-admin/index.tsx @@ -0,0 +1,148 @@ +/* eslint-disable react-hooks/exhaustive-deps */ +import { + BadgeCustom, + CenterCustom, + Divider, + SearchInput, + StackCustom, + TextCustom, + ViewWrapper, +} from "@/components"; +import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage"; +import { GridViewCustomSpan } from "@/components/_ShareComponent/GridViewCustomSpan"; +import { AccentColor, MainColor } from "@/constants/color-palet"; +import { ICON_SIZE_XLARGE } from "@/constants/constans-value"; +import { apiAdminUserAccessGetAll } from "@/service/api-admin/api-admin-user-access"; +import { Ionicons } from "@expo/vector-icons"; + +import { router, useFocusEffect } from "expo-router"; +import _ from "lodash"; +import { useCallback, useState } from "react"; + +export default function SuperAdmin_ListUser() { + const [listData, setListData] = useState(null); + const [search, setSearch] = useState(""); + + useFocusEffect( + useCallback(() => { + onLoadData(); + }, [search]) + ); + + const onLoadData = async () => { + try { + const response = await apiAdminUserAccessGetAll({ + search: search, + category: "all-role", + }); + + if (response.success) { + setListData(response.data); + } + } catch (error) { + console.log("[ERROR LOAD DATA]", error); + } + }; + + const rightComponent = () => { + return ( + <> + setSearch(text)} + /> + + ); + }; + + return ( + <> + + } + > + + Aksi + + } + component2={ + + Username + + } + component3={ + + Role + + } + /> + + + + + {_.isEmpty(listData) ? ( + + Tidak ada data + + ) : ( + listData?.map((item: any, index: number) => ( + + + router.push(`/admin/super-admin/${item?.id}`) + } + name="open" + size={ICON_SIZE_XLARGE} + color={MainColor.yellow} + /> + + + // + // router.push(`/admin/super-admin/${item?.id}`) + // } + // > + // Detail + // + } + component2={ + + {item?.username || "-"} + + } + component3={ + + {item?.masterUserRoleId === "2" ? ( + Admin + ) : ( + + User + + )} + + } + style3={{ alignItems: "center", justifyContent: "center" }} + /> + )) + )} + + + + ); +} diff --git a/app/(application)/admin/user-access.tsx b/app/(application)/admin/user-access.tsx deleted file mode 100644 index 8176c9d..0000000 --- a/app/(application)/admin/user-access.tsx +++ /dev/null @@ -1,117 +0,0 @@ -import { - ButtonCustom, - Divider, - Grid, - SearchInput, - StackCustom, - TextCustom, - ViewWrapper -} from "@/components"; -import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage"; -import { MainColor } from "@/constants/color-palet"; -import { ICON_SIZE_MEDIUM } from "@/constants/constans-value"; -import { Ionicons } from "@expo/vector-icons"; - -export default function AdminUserAccess() { - const rightComponent = () => { - return ( - <> - - - ); - }; - return ( - <> - - } - > - - - Aksi - - - Username - - - Nomor - - - - - - - {Array.from({ length: 10 }).map((_, index) => ( - - - - - } - onPress={() => {}} - backgroundColor={ - index % 2 === 0 ? MainColor.green : MainColor.red - } - > - - {index % 2 === 0 ? "Berikan Akses" : "Hapus Akses"} - - - - - - - Useraname - - - - - 08123456789 - - - - ))} - - - - ); -} diff --git a/app/(application)/admin/user-access/[id]/index.tsx b/app/(application)/admin/user-access/[id]/index.tsx new file mode 100644 index 0000000..3905612 --- /dev/null +++ b/app/(application)/admin/user-access/[id]/index.tsx @@ -0,0 +1,124 @@ +/* eslint-disable react-hooks/exhaustive-deps */ +import { + BoxButtonOnFooter, + ButtonCustom, + LoaderCustom, + StackCustom, + TextCustom, + ViewWrapper, +} from "@/components"; +import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle"; +import GridTwoView from "@/components/_ShareComponent/GridTwoView"; +import { + apiAdminUserAccessGetById, + apiAdminUserAccessUpdateStatus, +} from "@/service/api-admin/api-admin-user-access"; +import { router, useFocusEffect, useLocalSearchParams } from "expo-router"; +import { useCallback, useState } from "react"; +import Toast from "react-native-toast-message"; + +export default function AdminUserAccessDetail() { + const { id } = useLocalSearchParams(); + const [data, setData] = useState(null); + const [loadData, setLoadData] = useState(false); + const [isLoading, setLoading] = useState(false); + + useFocusEffect( + useCallback(() => { + onLoadData(); + }, [id]) + ); + + const onLoadData = async () => { + try { + setLoadData(true); + const response = await apiAdminUserAccessGetById({ id: id as string }); + + setData(response.data); + } catch (error) { + console.log("[ERROR LOAD DATA]", error); + } finally { + setLoadData(false); + } + }; + + const handlerSubmit = async () => { + try { + setLoading(true); + const response = await apiAdminUserAccessUpdateStatus({ + id: id as string, + active: !data?.active, + }); + + if (!response.success) { + Toast.show({ + type: "error", + text1: "Update aktifasi gagal", + }); + return; + } + Toast.show({ + type: "success", + text1: "Update aktifasi berhasil ", + }); + router.back(); + } catch (error) { + console.log("[ERROR UPDATE STATUS]", error); + } finally { + setLoading(false); + } + }; + + return ( + <> + } + footerComponent={ + data && ( + + + {data?.active ? "Hapus Akses" : "Berikan Akses"} + + + ) + } + > + {loadData ? ( + + ) : ( + + {listData(data && data)?.map((item: any, index: number) => ( + {item?.label}} + rightIcon={{item?.value}} + /> + ))} + + )} + + + ); +} + +const listData = (data: any) => [ + { + label: "Username", + value: (data && data?.username) || "-", + }, + { + label: "Aktivasi", + value: data && data?.active ? "Aktif" : "Tidak Aktif", + }, + { + label: "Nomor", + value: (data && `+${data?.nomor}`) || "-", + }, +]; diff --git a/app/(application)/admin/user-access/index.tsx b/app/(application)/admin/user-access/index.tsx new file mode 100644 index 0000000..8a7f877 --- /dev/null +++ b/app/(application)/admin/user-access/index.tsx @@ -0,0 +1,143 @@ +/* eslint-disable react-hooks/exhaustive-deps */ +import { + BadgeCustom, + CenterCustom, + Divider, + SearchInput, + StackCustom, + TextCustom, + ViewWrapper, +} from "@/components"; +import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage"; +import { GridViewCustomSpan } from "@/components/_ShareComponent/GridViewCustomSpan"; +import { MainColor } from "@/constants/color-palet"; +import { ICON_SIZE_XLARGE } from "@/constants/constans-value"; +import { apiAdminUserAccessGetAll } from "@/service/api-admin/api-admin-user-access"; +import { Ionicons } from "@expo/vector-icons"; +import { router, useFocusEffect } from "expo-router"; +import _ from "lodash"; +import { useCallback, useState } from "react"; + +export default function AdminUserAccess() { + const [listData, setListData] = useState(null); + const [search, setSearch] = useState(""); + + useFocusEffect( + useCallback(() => { + onLoadData(); + }, [search]) + ); + + const onLoadData = async () => { + try { + const response = await apiAdminUserAccessGetAll({ + search: search, + category: "only-user", + }); + + if (response.success) { + setListData(response.data); + } + } catch (error) { + console.log("[ERROR LOAD DATA]", error); + } + }; + + const rightComponent = () => { + return ( + <> + setSearch(text)} + /> + + ); + }; + return ( + <> + + } + > + + Aksi + + } + component2={ + + Username + + } + component3={ + + Status Akses + + } + /> + + + + + {_.isEmpty(listData) ? ( + + Tidak ada data + + ) : ( + listData?.map((item: any, index: number) => ( + + + router.push(`/admin/user-access/${item?.id}`) + } + name="open" + size={ICON_SIZE_XLARGE} + color={MainColor.yellow} + /> + + // + // router.push(`/admin/user-access/${item?.id}`) + // } + // > + // Detail + // + } + component2={ + + {item?.username || "-"} + + } + component3={ + + {item?.active ? ( + Aktif + ) : ( + Tidak Aktif + )} + + } + style3={{ alignItems: "center", justifyContent: "center" }} + /> + )) + )} + + + + ); +} diff --git a/components/ActionIcon/ActionIcon.tsx b/components/ActionIcon/ActionIcon.tsx index a808919..7b238a6 100644 --- a/components/ActionIcon/ActionIcon.tsx +++ b/components/ActionIcon/ActionIcon.tsx @@ -1,6 +1,6 @@ import { MainColor } from "@/constants/color-palet"; import { Href, router } from "expo-router"; -import { DimensionValue, TouchableOpacity } from "react-native"; +import { DimensionValue, StyleProp, TouchableOpacity, ViewStyle } from "react-native"; type SizeType = "xs" | "sm" | "md" | "lg" | "xl" | number | string | undefined; @@ -10,12 +10,14 @@ export default function ActionIcon({ icon, size = "md", disabled = false, + style, }: { href?: Href; onPress?: () => void; icon: React.ReactNode; size?: SizeType; disabled?: boolean; + style?: StyleProp; }) { const sizeMap = { xs: 22, @@ -39,7 +41,7 @@ export default function ActionIcon({ { if (disabled) return; if (href) { diff --git a/components/_ShareComponent/GridTwoView.tsx b/components/_ShareComponent/GridTwoView.tsx index 0aaabb4..d919d17 100644 --- a/components/_ShareComponent/GridTwoView.tsx +++ b/components/_ShareComponent/GridTwoView.tsx @@ -1,4 +1,4 @@ -import { StyleProp, ViewStyle } from "react-native"; +import { ViewStyle } from "react-native"; import Grid from "../Grid/GridCustom"; export default function GridTwoView({ @@ -13,15 +13,23 @@ export default function GridTwoView({ spanRight?: number; leftIcon?: React.ReactNode; rightIcon?: React.ReactNode; - styleLeft?: StyleProp; - styleRight?: StyleProp; + styleLeft?: ViewStyle; + styleRight?: ViewStyle; }) { + const baseStyle: ViewStyle = { justifyContent: "center" }; + return ( - + {leftIcon} - + {rightIcon} diff --git a/components/_ShareComponent/GridViewCustomSpan.tsx b/components/_ShareComponent/GridViewCustomSpan.tsx index 329b76e..c2d1c45 100644 --- a/components/_ShareComponent/GridViewCustomSpan.tsx +++ b/components/_ShareComponent/GridViewCustomSpan.tsx @@ -1,4 +1,5 @@ import { Grid } from "@/components"; +import { StyleProp, ViewStyle } from "react-native"; export const GridViewCustomSpan = ({ span1, @@ -7,31 +8,52 @@ export const GridViewCustomSpan = ({ component1, component2, component3, + style1, + style2, + style3, }: { - span1: number; - span2: number; - span3: number; + span1?: number; + span2?: number; + span3?: number; component1: React.ReactNode; component2: React.ReactNode; component3: React.ReactNode; + style1?: StyleProp; + style2?: StyleProp; + style3?: StyleProp; }) => { return ( {component1} {component2} {component3} diff --git a/context/AuthContext.tsx b/context/AuthContext.tsx index 94e3523..67d2f43 100644 --- a/context/AuthContext.tsx +++ b/context/AuthContext.tsx @@ -135,7 +135,7 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => { const userData = async (token: string) => { try { setIsLoading(true); - const response = await apiConfig.get(`/mobile/user?token=${token}`, { + const response = await apiConfig.get(`/mobile?token=${token}`, { headers: { Authorization: `Bearer ${token}`, }, diff --git a/screens/Admin/listPageAdmin.tsx b/screens/Admin/listPageAdmin.tsx index 8b9fb8f..ace1df1 100644 --- a/screens/Admin/listPageAdmin.tsx +++ b/screens/Admin/listPageAdmin.tsx @@ -1,6 +1,6 @@ import { NavbarItem } from "@/components/Drawer/NavbarMenu"; -export { adminListMenu } +export { adminListMenu, superAdminListMenu } const adminListMenu: NavbarItem[] = [ { @@ -93,4 +93,102 @@ const adminListMenu: NavbarItem[] = [ icon: "people", link: "/admin/user-access", }, +]; + +const superAdminListMenu: NavbarItem[] = [ + { + label: "Main Dashboard", + icon: "home", + link: "/admin/dashboard", + }, + { + label: "Investasi", + icon: "wallet", + links: [ + { label: "Dashboard", link: "/admin/investment" }, + { label: "Publish", link: "/admin/investment/publish/status" }, + { label: "Review", link: "/admin/investment/review/status" }, + { label: "Reject", link: "/admin/investment/reject/status" }, + ], + }, + { + label: "Donasi", + icon: "hand-right", + links: [ + { label: "Dashboard", link: "/admin/donation" }, + { label: "Publish", link: "/admin/donation/publish/status" }, + { label: "Review", link: "/admin/donation/review/status" }, + { label: "Reject", link: "/admin/donation/reject/status" }, + { label: "Kategori", link: "/admin/donation/category" }, + ], + }, + { + label: "Event", + icon: "calendar-clear", + links: [ + { label: "Dashboard", link: "/admin/event" }, + { label: "Publish", link: "/admin/event/publish/status" }, + { label: "Review", link: "/admin/event/review/status" }, + { label: "Reject", link: "/admin/event/reject/status" }, + { label: "Tipe Acara", link: "/admin/event/type-of-event" }, + { label: "Riwayat", link: "/admin/event/riwayat/status" }, + ], + }, + { + label: "Voting", + icon: "accessibility-outline", + links: [ + { label: "Dashboard", link: "/admin/voting" }, + { label: "Publish", link: "/admin/voting/publish/status" }, + { label: "Review", link: "/admin/voting/review/status" }, + { label: "Reject", link: "/admin/voting/reject/status" }, + { label: "Riwayat", link: "/admin/voting/riwayat/status" }, + ], + }, + { + label: "Job", + icon: "desktop-outline", + links: [ + { label: "Dashboard", link: "/admin/job" }, + { label: "Publish", link: "/admin/job/publish/status" }, + { label: "Review", link: "/admin/job/review/status" }, + { label: "Reject", link: "/admin/job/reject/status" }, + ], + }, + { + label: "Forum", + icon: "chatbubble-ellipses-outline", + links: [ + { label: "Dashboard", link: "/admin/forum" }, + { label: "Posting", link: "/admin/forum/posting" }, + { label: "Report Posting", link: "/admin/forum/report-posting" }, + { label: "Report Comment", link: "/admin/forum/report-comment" }, + ], + }, + { + label: "Collaboration", + icon: "people", + links: [ + { label: "Dashboard", link: "/admin/collaboration" }, + { label: "Publish", link: "/admin/collaboration/publish" }, + { label: "Group", link: "/admin/collaboration/group" }, + { label: "Reject", link: "/admin/collaboration/reject" }, + ], + }, + { label: "Maps", icon: "map", link: "/admin/maps" }, + { + label: "App Information", + icon: "information-circle", + link: "/admin/app-information", + }, + { + label: "User Access", + icon: "people", + link: "/admin/user-access", + }, + { + label: "Super Admin", + icon: "globe", + link: "/admin/super-admin", + }, ]; \ No newline at end of file diff --git a/service/api-admin/api-admin-main-dashboard.ts b/service/api-admin/api-admin-main-dashboard.ts new file mode 100644 index 0000000..65a3072 --- /dev/null +++ b/service/api-admin/api-admin-main-dashboard.ts @@ -0,0 +1,10 @@ +import { apiConfig } from "../api-config"; + +export const apiAdminMainDashboardGetAll = async () => { + try { + const response = await apiConfig.get(`/mobile/admin/main-dashboard`); + return response.data; + } catch (error) { + console.log(error); + } +}; diff --git a/service/api-admin/api-admin-user-access.ts b/service/api-admin/api-admin-user-access.ts new file mode 100644 index 0000000..eacf6f2 --- /dev/null +++ b/service/api-admin/api-admin-user-access.ts @@ -0,0 +1,47 @@ +import { apiConfig } from "../api-config"; + +export const apiAdminUserAccessGetAll = async ({ + search, + category, +}: { + search?: string; + category: "only-user" | "only-admin" | "all-role"; +}) => { + try { + const response = await apiConfig.get(`/mobile/admin/user?category=${category}&search=${search}`); + return response.data; + } catch (error) { + console.log(error); + } +}; + +export const apiAdminUserAccessGetById = async ({ id }: { id: string }) => { + try { + const response = await apiConfig.get(`/mobile/admin/user/${id}`); + return response.data; + } catch (error) { + console.log(error); + } +}; + +export const apiAdminUserAccessUpdateStatus = async ({ + id, + active, + role, +}: { + id: string; + active?: boolean; + role?: "user" | "admin" | "super_admin"; +}) => { + try { + const response = await apiConfig.put(`/mobile/admin/user/${id}`, { + data: { + active, + role, + }, + }); + return response.data; + } catch (error) { + console.log(error); + } +};