2025-12-22 09:36:23 +09:00
|
|
|
/**
|
|
|
|
|
* 관리자 페이지
|
|
|
|
|
*/
|
|
|
|
|
|
2025-12-22 11:42:37 +09:00
|
|
|
import { useEffect, useState } from 'react';
|
2025-12-22 14:57:34 +09:00
|
|
|
import { useNavigate, useLocation, Link } from 'react-router-dom';
|
2025-12-22 09:36:23 +09:00
|
|
|
import { useAuth } from '../contexts/AuthContext';
|
2025-12-22 14:57:34 +09:00
|
|
|
import { Shield, ArrowLeft, Settings, Server, Users, Loader2, User, Terminal, MessageSquare } from 'lucide-react';
|
2025-12-22 11:42:37 +09:00
|
|
|
import { motion, AnimatePresence } from 'framer-motion';
|
2025-12-22 09:36:23 +09:00
|
|
|
|
2025-12-22 14:57:34 +09:00
|
|
|
export default function Admin({ isMobile = false }) {
|
|
|
|
|
const { isLoggedIn, isAdmin, user, loading } = useAuth();
|
2025-12-22 09:36:23 +09:00
|
|
|
const navigate = useNavigate();
|
2025-12-22 11:42:37 +09:00
|
|
|
const location = useLocation();
|
|
|
|
|
const [toast, setToast] = useState(null);
|
2025-12-22 09:36:23 +09:00
|
|
|
|
|
|
|
|
// 권한 확인
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (!loading) {
|
|
|
|
|
if (!isLoggedIn) {
|
2025-12-22 11:42:37 +09:00
|
|
|
navigate('/login', { state: { from: location.pathname } });
|
2025-12-22 09:36:23 +09:00
|
|
|
} else if (!isAdmin) {
|
2025-12-22 11:42:37 +09:00
|
|
|
setToast('관리자 권한이 필요합니다.');
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
navigate('/');
|
|
|
|
|
}, 1500);
|
2025-12-22 09:36:23 +09:00
|
|
|
}
|
|
|
|
|
}
|
2025-12-22 11:42:37 +09:00
|
|
|
}, [isLoggedIn, isAdmin, loading, navigate, location.pathname]);
|
2025-12-22 09:36:23 +09:00
|
|
|
|
2025-12-22 11:42:37 +09:00
|
|
|
// 토스트 자동 숨기기
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (toast) {
|
|
|
|
|
const timer = setTimeout(() => setToast(null), 3000);
|
|
|
|
|
return () => clearTimeout(timer);
|
|
|
|
|
}
|
|
|
|
|
}, [toast]);
|
|
|
|
|
|
2025-12-22 09:36:23 +09:00
|
|
|
if (loading) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex items-center justify-center min-h-[60vh]">
|
|
|
|
|
<Loader2 className="w-8 h-8 text-mc-green animate-spin" />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isLoggedIn || !isAdmin) {
|
2025-12-22 11:42:37 +09:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{/* 토스트 알림 */}
|
|
|
|
|
<AnimatePresence>
|
|
|
|
|
{toast && (
|
|
|
|
|
<motion.div
|
|
|
|
|
initial={{ opacity: 0, y: 50 }}
|
|
|
|
|
animate={{ opacity: 1, y: 0 }}
|
|
|
|
|
exit={{ opacity: 0, y: 50 }}
|
|
|
|
|
className="fixed bottom-8 left-1/2 -translate-x-1/2 z-[200] bg-red-500/90 backdrop-blur-sm text-white px-6 py-3 rounded-xl text-center font-medium shadow-lg"
|
|
|
|
|
>
|
|
|
|
|
{toast}
|
|
|
|
|
</motion.div>
|
|
|
|
|
)}
|
|
|
|
|
</AnimatePresence>
|
|
|
|
|
<div className="flex items-center justify-center min-h-[60vh]">
|
|
|
|
|
<Loader2 className="w-8 h-8 text-mc-green animate-spin" />
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
2025-12-22 09:36:23 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2025-12-22 14:57:34 +09:00
|
|
|
<div className="pb-8">
|
|
|
|
|
{/* 모바일용 헤더 */}
|
|
|
|
|
{isMobile && (
|
|
|
|
|
<header className="bg-mc-dark border-b border-white/10 sticky top-0 z-50 backdrop-blur-xl">
|
|
|
|
|
<div className="flex items-center h-14 px-4">
|
|
|
|
|
<Link
|
|
|
|
|
to="/"
|
|
|
|
|
className="p-2 -ml-2 rounded-lg text-zinc-400 hover:text-white hover:bg-white/5 transition-colors"
|
|
|
|
|
>
|
|
|
|
|
<ArrowLeft size={20} />
|
|
|
|
|
</Link>
|
|
|
|
|
<div className="ml-2">
|
|
|
|
|
<h1 className="text-lg font-bold text-white">관리자</h1>
|
|
|
|
|
<p className="text-xs text-zinc-500">서버 관리 및 설정</p>
|
|
|
|
|
</div>
|
2025-12-22 09:36:23 +09:00
|
|
|
</div>
|
2025-12-22 14:57:34 +09:00
|
|
|
</header>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<main className={`max-w-4xl mx-auto px-4 sm:px-6 ${isMobile ? 'py-4' : 'py-8'} space-y-4 sm:space-y-6`}>
|
|
|
|
|
{/* 데스크탑용 타이틀 */}
|
|
|
|
|
{!isMobile && (
|
|
|
|
|
<div className="mb-6">
|
2025-12-22 09:36:23 +09:00
|
|
|
<h1 className="text-2xl font-bold text-white">관리자 페이지</h1>
|
2025-12-22 14:57:34 +09:00
|
|
|
<p className="text-sm text-zinc-500 mt-1">서버 관리 및 설정</p>
|
2025-12-22 09:36:23 +09:00
|
|
|
</div>
|
2025-12-22 14:57:34 +09:00
|
|
|
)}
|
2025-12-22 09:36:23 +09:00
|
|
|
|
2025-12-22 14:57:34 +09:00
|
|
|
{/* 관리자 정보 카드 */}
|
|
|
|
|
<section className="bg-zinc-900 border border-zinc-800 rounded-2xl p-6">
|
|
|
|
|
<h2 className="text-lg font-semibold text-white mb-6 flex items-center gap-2">
|
|
|
|
|
<Shield size={20} className="text-yellow-500" />
|
|
|
|
|
관리자 정보
|
|
|
|
|
</h2>
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center gap-6">
|
|
|
|
|
<div className="w-16 h-16 rounded-2xl bg-yellow-500/20 border border-yellow-500/30 flex items-center justify-center">
|
|
|
|
|
<User size={32} className="text-yellow-500" />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="flex-1 space-y-3">
|
|
|
|
|
<div>
|
|
|
|
|
<p className="text-sm text-zinc-500">닉네임</p>
|
|
|
|
|
<p className="text-lg font-medium text-white">{user?.name || '-'}</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<p className="text-sm text-zinc-500">이메일</p>
|
|
|
|
|
<p className="text-white">{user?.email}</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-12-22 09:36:23 +09:00
|
|
|
</div>
|
2025-12-22 14:57:34 +09:00
|
|
|
</section>
|
2025-12-22 09:36:23 +09:00
|
|
|
|
2025-12-22 14:57:34 +09:00
|
|
|
{/* 서버 관리 섹션 */}
|
|
|
|
|
<section className="bg-zinc-900 border border-zinc-800 rounded-2xl p-6">
|
|
|
|
|
<h2 className="text-lg font-semibold text-white mb-6 flex items-center gap-2">
|
|
|
|
|
<Server size={20} className="text-mc-green" />
|
|
|
|
|
서버 관리
|
|
|
|
|
</h2>
|
|
|
|
|
|
|
|
|
|
<div className="space-y-4">
|
|
|
|
|
{/* 서버 명령어 */}
|
|
|
|
|
<div className="p-4 bg-zinc-800/50 rounded-xl">
|
|
|
|
|
<div className="flex items-center gap-3 mb-2">
|
|
|
|
|
<Terminal size={18} className="text-zinc-400" />
|
|
|
|
|
<p className="font-medium text-white">서버 명령어</p>
|
|
|
|
|
</div>
|
|
|
|
|
<p className="text-sm text-zinc-400 mb-3">
|
|
|
|
|
마인크래프트 서버에 명령어를 전송합니다.
|
|
|
|
|
</p>
|
|
|
|
|
<div className="text-zinc-500 text-sm">
|
|
|
|
|
추후 업데이트 예정
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-12-22 09:36:23 +09:00
|
|
|
|
2025-12-22 14:57:34 +09:00
|
|
|
{/* 공지 전송 */}
|
|
|
|
|
<div className="p-4 bg-zinc-800/50 rounded-xl">
|
|
|
|
|
<div className="flex items-center gap-3 mb-2">
|
|
|
|
|
<MessageSquare size={18} className="text-zinc-400" />
|
|
|
|
|
<p className="font-medium text-white">공지 전송</p>
|
|
|
|
|
</div>
|
|
|
|
|
<p className="text-sm text-zinc-400 mb-3">
|
|
|
|
|
게임 내 모든 플레이어에게 공지를 전송합니다.
|
|
|
|
|
</p>
|
|
|
|
|
<div className="text-zinc-500 text-sm">
|
|
|
|
|
추후 업데이트 예정
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-12-22 09:36:23 +09:00
|
|
|
</div>
|
2025-12-22 14:57:34 +09:00
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
{/* 플레이어 관리 섹션 */}
|
|
|
|
|
<section className="bg-zinc-900 border border-zinc-800 rounded-2xl p-6">
|
|
|
|
|
<h2 className="text-lg font-semibold text-white mb-6 flex items-center gap-2">
|
|
|
|
|
<Users size={20} className="text-blue-400" />
|
|
|
|
|
플레이어 관리
|
|
|
|
|
</h2>
|
|
|
|
|
|
|
|
|
|
<p className="text-sm text-zinc-400">
|
2025-12-22 09:36:23 +09:00
|
|
|
접속 중인 플레이어 목록 및 관리 기능
|
|
|
|
|
</p>
|
|
|
|
|
<div className="mt-4 text-zinc-500 text-sm">
|
|
|
|
|
추후 업데이트 예정
|
|
|
|
|
</div>
|
2025-12-22 14:57:34 +09:00
|
|
|
</section>
|
2025-12-22 09:36:23 +09:00
|
|
|
|
2025-12-22 14:57:34 +09:00
|
|
|
{/* 설정 섹션 */}
|
|
|
|
|
<section className="bg-zinc-900 border border-zinc-800 rounded-2xl p-6">
|
|
|
|
|
<h2 className="text-lg font-semibold text-white mb-6 flex items-center gap-2">
|
|
|
|
|
<Settings size={20} className="text-zinc-400" />
|
|
|
|
|
설정
|
|
|
|
|
</h2>
|
|
|
|
|
|
|
|
|
|
<p className="text-sm text-zinc-400">
|
2025-12-22 09:36:23 +09:00
|
|
|
대시보드 설정 및 구성 관리
|
|
|
|
|
</p>
|
|
|
|
|
<div className="mt-4 text-zinc-500 text-sm">
|
|
|
|
|
추후 업데이트 예정
|
|
|
|
|
</div>
|
2025-12-22 14:57:34 +09:00
|
|
|
</section>
|
|
|
|
|
</main>
|
2025-12-22 09:36:23 +09:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-12-22 14:57:34 +09:00
|
|
|
|