diff --git a/CHANGELOG.md b/CHANGELOG.md index dd2aaac3..36aad57d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines. +## [1.2.38](https://github.com/bipproduction/hipmi/compare/v1.2.37...v1.2.38) (2025-01-03) + + +### Bug Fixes + +* user ([215accb](https://github.com/bipproduction/hipmi/commit/215accbcaa989e43f43dfc5f400d5411013f4ef3)) + ## [1.2.37](https://github.com/bipproduction/hipmi/compare/v1.2.36...v1.2.37) (2025-01-02) ## [1.2.36](https://github.com/bipproduction/hipmi/compare/v1.2.35...v1.2.36) (2024-12-30) diff --git a/package.json b/package.json index ff74e64c..d0cba3cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hipmi", - "version": "1.2.37", + "version": "1.2.38", "private": true, "prisma": { "seed": "npx tsx prisma/seed.ts --yes" diff --git a/src/app/(user)/waiting-room/page.tsx b/src/app/(user)/waiting-room/page.tsx index abb6e4d0..8d19813d 100644 --- a/src/app/(user)/waiting-room/page.tsx +++ b/src/app/(user)/waiting-room/page.tsx @@ -1,19 +1,12 @@ import { funGetUserIdByToken } from "@/app_modules/_global/fun/get"; -import { funGlobal_checkActivationUseById } from "@/app_modules/_global/fun/get/fun_check_activation_use_by_id"; import WaitingRoom_View from "@/app_modules/waiting_room/view"; export default async function Page() { const userLoginId = await funGetUserIdByToken(); - const activationUser = await funGlobal_checkActivationUseById({ - userId: userLoginId as string, - }); return ( <> - + ); } diff --git a/src/app/api/user/activation/route.ts b/src/app/api/user/activation/route.ts new file mode 100644 index 00000000..965e1805 --- /dev/null +++ b/src/app/api/user/activation/route.ts @@ -0,0 +1,53 @@ +import { prisma } from "@/app/lib"; +import { funGetUserIdByToken } from "@/app_modules/_global/fun/get"; +import backendLogger from "@/util/backendLogger"; +import { NextResponse } from "next/server"; + +export const dynamic = "force-dynamic"; + +export async function GET(request: Request) { + try { + let fixData + const userLoginId = await funGetUserIdByToken(); + + if (userLoginId == null) { + return NextResponse.json( + { + success: false, + message: "Gagal mendapatkan data, user id tidak ada", + }, + { status: 500 } + ); + } + + const activationUser = await prisma.user.findFirst({ + where: { + id: userLoginId, + }, + select: { + active: true, + }, + }); + + fixData = activationUser?.active + + return NextResponse.json( + { + success: true, + message: "Berhasil mendapatkan data", + data: fixData, + }, + { status: 200 } + ); + } catch (error) { + backendLogger.error("Error get activation user: ", error); + return NextResponse.json( + { + success: false, + message: "Gagal mendapatkan data", + reason: (error as Error).message, + }, + { status: 500 } + ); + } +} diff --git a/src/app/api/user/route.ts b/src/app/api/user/get/route.ts similarity index 100% rename from src/app/api/user/route.ts rename to src/app/api/user/get/route.ts diff --git a/src/app/api/validasi/route.ts b/src/app/api/validation/route.ts similarity index 78% rename from src/app/api/validasi/route.ts rename to src/app/api/validation/route.ts index 4562aa95..6b420a9e 100644 --- a/src/app/api/validasi/route.ts +++ b/src/app/api/validation/route.ts @@ -1,9 +1,16 @@ + import { NextResponse } from "next/server"; + export async function GET(req: Request) { const auth = req.headers.get("Authorization"); const token = auth?.split(" ")[1]; - if (!token) return NextResponse.json({ success: false }, { status: 401 }); - return NextResponse.json({ success: true }); + console.log("validasi atas", token); + + if (!token) return NextResponse.json({ success: false }, { status: 401 }); + + console.log("validasi bawah", token); + + return NextResponse.json({ success: true }); } diff --git a/src/app/zCoba/skeleton/page.tsx b/src/app/zCoba/skeleton/page.tsx index f16ec3cf..a5b62d10 100644 --- a/src/app/zCoba/skeleton/page.tsx +++ b/src/app/zCoba/skeleton/page.tsx @@ -5,7 +5,8 @@ import { UIGlobal_LayoutHeaderTamplate, UIGlobal_LayoutTamplate, } from "@/app_modules/_global/ui"; -import { Grid, Skeleton, Stack } from "@mantine/core"; +import { Button, Grid, Skeleton, Stack } from "@mantine/core"; +import Link from "next/link"; export default function Voting_ComponentSkeletonViewPuh() { return ( @@ -13,6 +14,25 @@ export default function Voting_ComponentSkeletonViewPuh() { } > + + diff --git a/src/app_modules/_global/lib/api_user.ts b/src/app_modules/_global/lib/api_user.ts new file mode 100644 index 00000000..7c868120 --- /dev/null +++ b/src/app_modules/_global/lib/api_user.ts @@ -0,0 +1,9 @@ +export const apiGetCookiesUser = async () => { + const response = await fetch(`/api/user/get`); + return await response.json().catch(() => null); +}; + +export const apiGetACtivationUser = async () => { + const response = await fetch(`/api/user/activation`); + return await response.json().catch(() => null); +}; \ No newline at end of file diff --git a/src/app_modules/admin/developer/index.tsx b/src/app_modules/admin/developer/index.tsx index eb0bf165..a04161b1 100644 --- a/src/app_modules/admin/developer/index.tsx +++ b/src/app_modules/admin/developer/index.tsx @@ -44,7 +44,7 @@ export default function AdminDeveloper({ return ( <> - + {/* - Table User NEW + Table User } radius={"xl"} diff --git a/src/app_modules/admin/new_list_page.tsx b/src/app_modules/admin/new_list_page.tsx index b9ab8119..ae940513 100644 --- a/src/app_modules/admin/new_list_page.tsx +++ b/src/app_modules/admin/new_list_page.tsx @@ -297,10 +297,10 @@ export const newListAdminPage = [ child: [], }, - // Developer + // Developer | Super Admin { - id: "Developer", - name: "Developer", + id: "Super Admin", + name: "Super Admin", path: RouterAdminDeveloper.main, icon: , child: [], diff --git a/src/app_modules/admin/user-access/view/index.tsx b/src/app_modules/admin/user-access/view/index.tsx index 06c97ad4..6180b6b5 100644 --- a/src/app_modules/admin/user-access/view/index.tsx +++ b/src/app_modules/admin/user-access/view/index.tsx @@ -1,6 +1,9 @@ "use client"; +import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil"; +import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal"; import { MODEL_USER } from "@/app_modules/home/model/interface"; +import { clientLogger } from "@/util/clientLogger"; import { Button, Center, @@ -14,48 +17,67 @@ import { Title, } from "@mantine/core"; import { IconSearch } from "@tabler/icons-react"; -import adminUserAccess_funEditAccess from "../fun/edit/fun_edit_access"; import { useState } from "react"; +import adminUserAccess_funEditAccess from "../fun/edit/fun_edit_access"; import adminUserAccess_getListUser from "../fun/get/get_list_all_user"; -import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil"; -import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal"; export default function AdminUserAccess_View({ listUser }: { listUser: any }) { const [data, setData] = useState(listUser.data); const [isActivePage, setActivePage] = useState(1); const [isNPage, setNPage] = useState(listUser.nPage); const [isSearch, setSearch] = useState(""); + const [isLoadingAccess, setIsLoadingAccess] = useState(false); + const [isLoadingDelete, setIsLoadingDelete] = useState(false); + const [userId, setUserId] = useState(""); async function onAccess(id: string) { - await adminUserAccess_funEditAccess(id, true).then(async (res) => { - if (res.status === 200) { - const value = await adminUserAccess_getListUser({ - page: 1, - search: isSearch, - }); - setData(value.data as any); - setNPage(value.nPage); - ComponentGlobal_NotifikasiBerhasil(res.message); - } else { - ComponentGlobal_NotifikasiGagal(res.message); - } - }); + try { + setUserId(id); + setIsLoadingAccess(true); + await adminUserAccess_funEditAccess(id, true).then(async (res) => { + if (res.status === 200) { + const value = await adminUserAccess_getListUser({ + page: 1, + search: isSearch, + }); + setData(value.data as any); + setNPage(value.nPage); + ComponentGlobal_NotifikasiBerhasil(res.message); + } else { + ComponentGlobal_NotifikasiGagal(res.message); + } + }); + } catch (error) { + clientLogger.error("Error grand access", error); + } finally { + setIsLoadingAccess(false); + setUserId(""); + } } - async function onDelAccess(id: string) { - await adminUserAccess_funEditAccess(id, false).then(async (res) => { - if (res.status === 200) { - const value = await adminUserAccess_getListUser({ - page: 1, - search: isSearch, - }); - setData(value.data as any); - setNPage(value.nPage); - ComponentGlobal_NotifikasiBerhasil(res.message); - } else { - ComponentGlobal_NotifikasiGagal(res.message); - } - }); + async function onDelete(id: string) { + try { + setUserId(id); + setIsLoadingDelete(true); + await adminUserAccess_funEditAccess(id, false).then(async (res) => { + if (res.status === 200) { + const value = await adminUserAccess_getListUser({ + page: 1, + search: isSearch, + }); + setData(value.data as any); + setNPage(value.nPage); + ComponentGlobal_NotifikasiBerhasil(res.message); + } else { + ComponentGlobal_NotifikasiGagal(res.message); + } + }); + } catch (error) { + clientLogger.error("Error delete access", error); + } finally { + setIsLoadingDelete(false); + setUserId(""); + } } async function onSearch(s: any) { @@ -91,22 +113,26 @@ export default function AdminUserAccess_View({ listUser }: { listUser: any }) { {e.active === false ? (
) : (