From f58a5afff55ef6b84314ff16726bc7a6b14e8ab7 Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Thu, 4 Apr 2024 14:32:48 +0800 Subject: [PATCH] # Developer ## feat - Memberi akses pada user menjadi admin ### No issue --- src/app/dev/admin/developer/loading.tsx | 9 + src/app/dev/admin/developer/page.tsx | 15 ++ src/app/dev/auth/login/layout.tsx | 14 -- .../router_admin/router_admin_developer.ts | 3 + src/app_modules/admin/component/logout.tsx | 40 ++- .../fun/edit/fun_edit_user_akses_by_id.ts | 23 ++ .../fun/get/fun_get_list_all_admin.ts | 15 ++ .../fun/get/fun_get_list_all_user.ts | 15 ++ src/app_modules/admin/developer/index.tsx | 232 ++++++++++++++++++ src/app_modules/admin/list_page.tsx | 3 +- src/app_modules/admin/splash/splash.tsx | 2 +- src/app_modules/auth/login/view.tsx | 97 +++----- 12 files changed, 389 insertions(+), 79 deletions(-) create mode 100644 src/app/dev/admin/developer/loading.tsx create mode 100644 src/app/dev/admin/developer/page.tsx delete mode 100644 src/app/dev/auth/login/layout.tsx create mode 100644 src/app/lib/router_admin/router_admin_developer.ts create mode 100644 src/app_modules/admin/developer/fun/edit/fun_edit_user_akses_by_id.ts create mode 100644 src/app_modules/admin/developer/fun/get/fun_get_list_all_admin.ts create mode 100644 src/app_modules/admin/developer/fun/get/fun_get_list_all_user.ts create mode 100644 src/app_modules/admin/developer/index.tsx diff --git a/src/app/dev/admin/developer/loading.tsx b/src/app/dev/admin/developer/loading.tsx new file mode 100644 index 00000000..96547f3a --- /dev/null +++ b/src/app/dev/admin/developer/loading.tsx @@ -0,0 +1,9 @@ +import ComponentAdminGlobal_LoadingPage from "@/app_modules/admin/component/loading_admin_page"; + +export default async function Page() { + return ( + <> + + + ); +} diff --git a/src/app/dev/admin/developer/page.tsx b/src/app/dev/admin/developer/page.tsx new file mode 100644 index 00000000..c69ae063 --- /dev/null +++ b/src/app/dev/admin/developer/page.tsx @@ -0,0 +1,15 @@ +import AdminDeveloper from "@/app_modules/admin/developer"; +import adminDeveloper_funGetListAllAdmin from "@/app_modules/admin/developer/fun/get/fun_get_list_all_admin"; +import adminDeveloper_funGetListAllUser from "@/app_modules/admin/developer/fun/get/fun_get_list_all_user"; +import _ from "lodash"; + +export default async function Page() { + const listUser = await adminDeveloper_funGetListAllUser(); + const listAdmin = await adminDeveloper_funGetListAllAdmin(); + + return ( + <> + + + ); +} diff --git a/src/app/dev/auth/login/layout.tsx b/src/app/dev/auth/login/layout.tsx deleted file mode 100644 index 79a8e50e..00000000 --- a/src/app/dev/auth/login/layout.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { LayoutLogin } from "@/app_modules/auth"; -import React from "react"; - -export default async function Layout({ - children, -}: { - children: React.ReactNode; -}) { - return ( - <> - {children} - - ); -} diff --git a/src/app/lib/router_admin/router_admin_developer.ts b/src/app/lib/router_admin/router_admin_developer.ts new file mode 100644 index 00000000..28c01626 --- /dev/null +++ b/src/app/lib/router_admin/router_admin_developer.ts @@ -0,0 +1,3 @@ +export const RouterAdminDeveloper = { + main: "/dev/admin/developer", +}; diff --git a/src/app_modules/admin/component/logout.tsx b/src/app_modules/admin/component/logout.tsx index 02e875f7..40caa8c6 100644 --- a/src/app_modules/admin/component/logout.tsx +++ b/src/app_modules/admin/component/logout.tsx @@ -1,7 +1,15 @@ "use client"; import { myConsole } from "@/app/fun/my_console"; import { ApiHipmi } from "@/app/lib/api"; -import { ActionIcon, Button, Group, Modal, Stack, Title } from "@mantine/core"; +import { + ActionIcon, + Button, + Group, + Loader, + Modal, + Stack, + Title, +} from "@mantine/core"; import { useRouter } from "next/navigation"; import { useAtom } from "jotai"; import { IconLogout } from "@tabler/icons-react"; @@ -16,6 +24,7 @@ import { useState } from "react"; export default function Admin_Logout() { const router = useRouter(); const [opened, { toggle }] = useDisclosure(false); + const [loading, setLoading] = useState(false); const [kodeId, setKodeId] = useAtom(gs_kodeId); const [loadingLogout, setLoadingLogout] = useState(false); @@ -34,15 +43,26 @@ export default function Admin_Logout() { return ( <> - + Anda yakin ingin keluar ? - + + + + )); + + return ( + <> + + + Table Admin + } + radius={"xl"} + placeholder="Masukan username" + /> + + + + + + + + + + + {tableBody} +
+
Username
+
+
Nomor
+
+
Aksi
+
+
+
+ + ); +} + +function TableUser({ + dataUser, + setDataUser, + setDataAdmin, +}: { + dataUser: MODEL_USER[]; + setDataUser: any; + setDataAdmin: any; +}) { + async function onAccess(id: string) { + await adminDeveloper_funEditUserAksesById(id, "2").then(async (res) => { + if (res.status === 200) { + await adminDeveloper_funGetListAllUser().then((val) => { + setDataUser(val); + }); + await adminDeveloper_funGetListAllAdmin().then((val) => { + setDataAdmin(val); + }); + ComponentGlobal_NotifikasiBerhasil(res.message); + } else { + ComponentGlobal_NotifikasiGagal(res.message); + } + }); + } + + const tableBody = dataUser.map((e) => ( + + +
{e.username}
+ + +
{e.nomor}
+ + +
+ +
+ + + )); + + return ( + <> + + + Table User + } + radius={"xl"} + placeholder="Masukan username" + /> + + + + + + + + + + + {tableBody} +
+
Username
+
+
Nomor
+
+
Aksi
+
+
+
+ + ); +} diff --git a/src/app_modules/admin/list_page.tsx b/src/app_modules/admin/list_page.tsx index cf051ac8..d7304746 100644 --- a/src/app_modules/admin/list_page.tsx +++ b/src/app_modules/admin/list_page.tsx @@ -1,3 +1,4 @@ +import { RouterAdminDeveloper } from "@/app/lib/router_admin/router_admin_developer"; import { RouterAdminEvent } from "@/app/lib/router_admin/router_admin_event"; import { RouterAdminForum } from "@/app/lib/router_admin/router_admin_forum"; import { RouterAdminJob } from "@/app/lib/router_admin/router_admin_job"; @@ -174,7 +175,7 @@ export const listAdminPage = [ { id: 99, name: "Developer", - path: RouterAdminDashboard.main_admin, + path: RouterAdminDeveloper.main, icon: , child: [], }, diff --git a/src/app_modules/admin/splash/splash.tsx b/src/app_modules/admin/splash/splash.tsx index 19f513f4..9fd04119 100644 --- a/src/app_modules/admin/splash/splash.tsx +++ b/src/app_modules/admin/splash/splash.tsx @@ -14,7 +14,7 @@ export default function SplashDashboardAdmin() { useShallowEffect(() => { setTimeout(() => { router.push(RouterAdminDashboard.main_admin); - setActive(0); + setActive(1); }, 2000); }, []); return ( diff --git a/src/app_modules/auth/login/view.tsx b/src/app_modules/auth/login/view.tsx index 485b71dc..a8dfc89f 100644 --- a/src/app_modules/auth/login/view.tsx +++ b/src/app_modules/auth/login/view.tsx @@ -79,67 +79,48 @@ export default function Login() { return ( <> -
- -
- logo -
- - Selamat Datang di HIPMI App - - Silahkan masukan nomor telepon anda untuk masuk ! - - - - {/* - -
- +62 -
-
- - { - setNomor(62 + val.target.value); - }} + +
+ +
+ logo - - */} +
+ + Selamat Datang di HIPMI App + + Silahkan masukan nomor telepon anda untuk masuk ! + + - { - setPhone(val); - }} - /> + { + setPhone(val); + }} + /> - -
-
+ +
+
+
); }