From b1e2f6012c47ad3a80ba2d056f934c0c17dd3bda Mon Sep 17 00:00:00 2001 From: wallace Date: Thu, 27 Nov 2025 20:36:38 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B6=8C=ED=95=9C=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=88=98=EC=A0=95/student?= =?UTF-8?q?=EB=A7=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/admin/id/mockData.ts | 11 ++++++++--- src/app/admin/id/page.tsx | 16 +++++++++++----- src/app/page.tsx | 16 ++++++++++++++-- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/app/admin/id/mockData.ts b/src/app/admin/id/mockData.ts index 4760f3c..ed8124b 100644 --- a/src/app/admin/id/mockData.ts +++ b/src/app/admin/id/mockData.ts @@ -22,17 +22,22 @@ export async function getInstructors(): Promise { ?.split('=')[1]) : null; - const apiUrl = process.env.NEXT_PUBLIC_API_BASE_URL + const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL ? `${process.env.NEXT_PUBLIC_API_BASE_URL}/admin/users/compact` : 'https://hrdi.coconutmeet.net/admin/users/compact'; + + // 쿼리 파라미터 추가: type=STUDENT, limit=10 + const apiUrl = new URL(baseUrl); + apiUrl.searchParams.set('type', 'STUDENT'); + apiUrl.searchParams.set('limit', '10'); console.log('🔍 [getInstructors] API 호출 정보:', { - url: apiUrl, + url: apiUrl.toString(), hasToken: !!token, tokenLength: token?.length || 0 }); - const response = await fetch(apiUrl, { + const response = await fetch(apiUrl.toString(), { method: 'GET', headers: { 'Content-Type': 'application/json', diff --git a/src/app/admin/id/page.tsx b/src/app/admin/id/page.tsx index b5207d1..a04ac41 100644 --- a/src/app/admin/id/page.tsx +++ b/src/app/admin/id/page.tsx @@ -51,11 +51,17 @@ export default function AdminIdPage() { ?.split('=')[1]; // 외부 API 호출 - const apiUrl = process.env.NEXT_PUBLIC_API_BASE_URL + const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL ? `${process.env.NEXT_PUBLIC_API_BASE_URL}/admin/users/compact` : 'https://hrdi.coconutmeet.net/admin/users/compact'; - const response = await fetch(apiUrl, { + // 쿼리 파라미터 추가: type=STUDENT, limit=10, page=currentPage + const apiUrl = new URL(baseUrl); + apiUrl.searchParams.set('type', 'STUDENT'); + apiUrl.searchParams.set('limit', '10'); + apiUrl.searchParams.set('page', String(currentPage)); + + const response = await fetch(apiUrl.toString(), { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -137,7 +143,7 @@ export default function AdminIdPage() { } fetchUsers(); - }, []); + }, [currentPage]); const filteredUsers = useMemo(() => { return activeTab === 'all' @@ -414,7 +420,7 @@ export default function AdminIdPage() { {/* 탭 네비게이션 */} -
+ {/*
{[ { id: 'all' as TabType, label: '전체' }, @@ -440,7 +446,7 @@ export default function AdminIdPage() { ))}
-
+
*/} {/* 콘텐츠 영역 */}
diff --git a/src/app/page.tsx b/src/app/page.tsx index a8c6731..9782865 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -2,9 +2,11 @@ 'use client'; import { useEffect, useMemo, useRef, useState } from 'react'; +import { useRouter } from 'next/navigation'; import MainLogoSvg from './svgs/mainlogosvg'; export default function Home() { + const router = useRouter(); const containerRef = useRef(null); const [currentIndex, setCurrentIndex] = useState(0); const [userName, setUserName] = useState(''); @@ -149,8 +151,18 @@ export default function Home() { const data = await response.json(); - if (isMounted && data.name) { - setUserName(data.name); + if (isMounted) { + // 사용자 권한 확인 + const userRole = data.role || data.userRole; + if (userRole === 'ADMIN' || userRole === 'admin') { + // admin 권한이면 /admin/id로 리다이렉트 + router.push('/admin/id'); + return; + } + + if (data.name) { + setUserName(data.name); + } } } catch (error) { console.error('사용자 정보 조회 오류:', error);