권한설정 페이지 수정/student만
This commit is contained in:
@@ -22,17 +22,22 @@ export async function getInstructors(): Promise<UserRow[]> {
|
|||||||
?.split('=')[1])
|
?.split('=')[1])
|
||||||
: null;
|
: 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`
|
? `${process.env.NEXT_PUBLIC_API_BASE_URL}/admin/users/compact`
|
||||||
: 'https://hrdi.coconutmeet.net/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 호출 정보:', {
|
console.log('🔍 [getInstructors] API 호출 정보:', {
|
||||||
url: apiUrl,
|
url: apiUrl.toString(),
|
||||||
hasToken: !!token,
|
hasToken: !!token,
|
||||||
tokenLength: token?.length || 0
|
tokenLength: token?.length || 0
|
||||||
});
|
});
|
||||||
|
|
||||||
const response = await fetch(apiUrl, {
|
const response = await fetch(apiUrl.toString(), {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|||||||
@@ -51,11 +51,17 @@ export default function AdminIdPage() {
|
|||||||
?.split('=')[1];
|
?.split('=')[1];
|
||||||
|
|
||||||
// 외부 API 호출
|
// 외부 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`
|
? `${process.env.NEXT_PUBLIC_API_BASE_URL}/admin/users/compact`
|
||||||
: 'https://hrdi.coconutmeet.net/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',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@@ -137,7 +143,7 @@ export default function AdminIdPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fetchUsers();
|
fetchUsers();
|
||||||
}, []);
|
}, [currentPage]);
|
||||||
|
|
||||||
const filteredUsers = useMemo(() => {
|
const filteredUsers = useMemo(() => {
|
||||||
return activeTab === 'all'
|
return activeTab === 'all'
|
||||||
@@ -414,7 +420,7 @@ export default function AdminIdPage() {
|
|||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
{/* 탭 네비게이션 */}
|
{/* 탭 네비게이션 */}
|
||||||
<div>
|
{/* <div>
|
||||||
<div className="flex items-center gap-8 border-b border-input-border">
|
<div className="flex items-center gap-8 border-b border-input-border">
|
||||||
{[
|
{[
|
||||||
{ id: 'all' as TabType, label: '전체' },
|
{ id: 'all' as TabType, label: '전체' },
|
||||||
@@ -440,7 +446,7 @@ export default function AdminIdPage() {
|
|||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> */}
|
||||||
|
|
||||||
{/* 콘텐츠 영역 */}
|
{/* 콘텐츠 영역 */}
|
||||||
<div className="flex-1 pt-8 flex flex-col">
|
<div className="flex-1 pt-8 flex flex-col">
|
||||||
|
|||||||
@@ -2,9 +2,11 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
import MainLogoSvg from './svgs/mainlogosvg';
|
import MainLogoSvg from './svgs/mainlogosvg';
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
|
const router = useRouter();
|
||||||
const containerRef = useRef<HTMLDivElement | null>(null);
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
||||||
const [currentIndex, setCurrentIndex] = useState(0);
|
const [currentIndex, setCurrentIndex] = useState(0);
|
||||||
const [userName, setUserName] = useState<string>('');
|
const [userName, setUserName] = useState<string>('');
|
||||||
@@ -149,9 +151,19 @@ export default function Home() {
|
|||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
if (isMounted && 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);
|
setUserName(data.name);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('사용자 정보 조회 오류:', error);
|
console.error('사용자 정보 조회 오류:', error);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user