50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
"use client";
|
|
|
|
import { useEffect, useState } from 'react';
|
|
import { useRouter } from 'next/navigation';
|
|
import { isAdminLoggedIn } from '../../lib/auth';
|
|
import LoginPage from '../login/page';
|
|
|
|
export default function AdminHomePage() {
|
|
const router = useRouter();
|
|
const [isLoading, setIsLoading] = useState(true);
|
|
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
|
|
|
useEffect(() => {
|
|
// 관리자 인증 확인
|
|
const checkAuth = () => {
|
|
if (typeof window !== 'undefined') {
|
|
const isAdmin = isAdminLoggedIn();
|
|
setIsAuthenticated(isAdmin);
|
|
setIsLoading(false);
|
|
|
|
if (!isAdmin) {
|
|
// 인증되지 않은 경우 로그인 페이지로 리다이렉트
|
|
router.push('/login');
|
|
}
|
|
}
|
|
};
|
|
|
|
checkAuth();
|
|
}, [router]);
|
|
|
|
if (isLoading) {
|
|
return null; // 로딩 중
|
|
}
|
|
|
|
if (!isAuthenticated) {
|
|
return <LoginPage />;
|
|
}
|
|
|
|
return (
|
|
<div className="bg-white relative size-full min-h-screen">
|
|
<div className="flex items-center justify-center min-h-screen">
|
|
<div className="text-center">
|
|
<h1 className="text-2xl font-bold text-[#404040] mb-4">관리자 홈</h1>
|
|
<p className="text-[#515151]">관리자 페이지에 오신 것을 환영합니다.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|