..
This commit is contained in:
@@ -22,8 +22,11 @@ import {
|
||||
Building,
|
||||
Star,
|
||||
Bug,
|
||||
Settings,
|
||||
Key,
|
||||
} from 'lucide-react';
|
||||
import { clsx } from 'clsx';
|
||||
import { comms } from '@/communication';
|
||||
import { UserInfoDialog } from '@/components/user/UserInfoDialog';
|
||||
import { UserGroupDialog } from '@/components/user/UserGroupDialog';
|
||||
import { KuntaeErrorCheckDialog } from '@/components/kuntae/KuntaeErrorCheckDialog';
|
||||
@@ -39,6 +42,7 @@ interface NavItem {
|
||||
icon: React.ElementType;
|
||||
label: string;
|
||||
action?: string;
|
||||
className?: string; // 추가: 클래스 이름
|
||||
}
|
||||
|
||||
interface SubMenu {
|
||||
@@ -54,6 +58,7 @@ interface MenuItem {
|
||||
label: string;
|
||||
submenu?: SubMenu;
|
||||
action?: string;
|
||||
className?: string; // gold 등 스타일 적용용
|
||||
}
|
||||
|
||||
interface DropdownMenuConfig {
|
||||
@@ -78,6 +83,13 @@ const leftDropdownMenus: DropdownMenuConfig[] = [
|
||||
{ type: 'action', icon: AlertTriangle, label: '오류검사', action: 'kuntaeErrorCheck' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '관리',
|
||||
icon: Settings,
|
||||
items: [
|
||||
{ type: 'link', path: '/license', icon: Key, label: '라이선스' },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
// 좌측 단독 액션 버튼
|
||||
@@ -90,44 +102,54 @@ const rightNavItems: NavItem[] = [
|
||||
];
|
||||
|
||||
// 드롭다운 메뉴 (2단계 지원)
|
||||
const dropdownMenus: DropdownMenuConfig[] = [
|
||||
{
|
||||
label: '공용정보',
|
||||
icon: Database,
|
||||
items: [
|
||||
{ type: 'link', path: '/common', icon: Code, label: '공용코드' },
|
||||
{ type: 'link', path: '/items', icon: Package, label: '품목정보' },
|
||||
{ type: 'link', path: '/customs', icon: Building, label: '업체정보' },
|
||||
{
|
||||
type: 'submenu',
|
||||
icon: Users,
|
||||
label: '사용자',
|
||||
submenu: {
|
||||
label: '사용자',
|
||||
const getDropdownMenus = (userLevel: number, userCode: string): DropdownMenuConfig[] => {
|
||||
const mailListItem = {
|
||||
type: 'link' as const,
|
||||
path: '/mail-list',
|
||||
icon: Mail,
|
||||
label: '메일 내역',
|
||||
className: (userCode === '395552') ? 'text-[gold] font-bold' : '',
|
||||
};
|
||||
|
||||
return [
|
||||
{
|
||||
label: '공용정보',
|
||||
icon: Database,
|
||||
items: [
|
||||
{ type: 'link', path: '/common', icon: Code, label: '공용코드' },
|
||||
{ type: 'link', path: '/items', icon: Package, label: '품목정보' },
|
||||
{ type: 'link', path: '/customs', icon: Building, label: '업체정보' },
|
||||
{
|
||||
type: 'submenu',
|
||||
icon: Users,
|
||||
items: [
|
||||
{ icon: User, label: '정보', action: 'userInfo' },
|
||||
{ path: '/user/list', icon: Users, label: '목록' },
|
||||
{ path: '/user/auth', icon: Shield, label: '권한' },
|
||||
{ icon: Users, label: '그룹정보', action: 'userGroup' },
|
||||
],
|
||||
label: '사용자',
|
||||
submenu: {
|
||||
label: '사용자',
|
||||
icon: Users,
|
||||
items: [
|
||||
{ icon: User, label: '정보', action: 'userInfo' },
|
||||
{ path: '/user/list', icon: Users, label: '목록' },
|
||||
{ path: '/user/auth', icon: Shield, label: '권한' },
|
||||
{ icon: Users, label: '그룹정보', action: 'userGroup' },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{ type: 'link', path: '/monthly-work', icon: CalendarDays, label: '월별근무표' },
|
||||
{ type: 'link', path: '/mail-form', icon: Mail, label: '메일양식' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '문서',
|
||||
icon: FileText,
|
||||
items: [
|
||||
{ type: 'link', path: '/note', icon: FileText, label: '메모장' },
|
||||
{ type: 'link', path: '/patch-list', icon: FileText, label: '패치 내역' },
|
||||
{ type: 'link', path: '/bug-report', icon: Bug, label: '버그 신고' },
|
||||
{ type: 'link', path: '/mail-list', icon: Mail, label: '메일 내역' },
|
||||
],
|
||||
},
|
||||
];
|
||||
{ type: 'link', path: '/monthly-work', icon: CalendarDays, label: '월별근무표' },
|
||||
{ type: 'link', path: '/mail-form', icon: Mail, label: '메일양식' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '문서',
|
||||
icon: FileText,
|
||||
items: [
|
||||
{ type: 'link', path: '/note', icon: FileText, label: '메모장' },
|
||||
{ type: 'link', path: '/patch-list', icon: FileText, label: '패치 내역' },
|
||||
{ type: 'link', path: '/bug-report', icon: Bug, label: '버그 신고' },
|
||||
...(userLevel >= 9 || userCode === '395552' ? [mailListItem] : []),
|
||||
],
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
function DropdownNavMenu({
|
||||
menu,
|
||||
@@ -194,7 +216,7 @@ function DropdownNavMenu({
|
||||
'flex items-center space-x-2 px-4 py-2 text-sm transition-colors',
|
||||
isActive
|
||||
? 'bg-white/20 text-white'
|
||||
: 'text-white/70 hover:bg-white/10 hover:text-white'
|
||||
: (item.className || 'text-white/70 hover:bg-white/10 hover:text-white')
|
||||
)
|
||||
}
|
||||
>
|
||||
@@ -326,7 +348,7 @@ function MobileDropdownMenu({
|
||||
'flex items-center space-x-3 px-4 py-2 rounded-lg transition-all duration-200',
|
||||
isActive
|
||||
? 'bg-white/20 text-white'
|
||||
: 'text-white/70 hover:bg-white/10 hover:text-white'
|
||||
: (item.className || 'text-white/70 hover:bg-white/10 hover:text-white')
|
||||
)
|
||||
}
|
||||
>
|
||||
@@ -373,7 +395,7 @@ function MobileDropdownMenu({
|
||||
'flex items-center space-x-3 px-4 py-2 rounded-lg transition-all duration-200',
|
||||
isActive
|
||||
? 'bg-white/20 text-white'
|
||||
: 'text-white/70 hover:bg-white/10 hover:text-white'
|
||||
: (item.className || 'text-white/70 hover:bg-white/10 hover:text-white')
|
||||
)
|
||||
}
|
||||
>
|
||||
@@ -409,6 +431,27 @@ export function Header(_props: HeaderProps) {
|
||||
const [showUserGroupDialog, setShowUserGroupDialog] = useState(false);
|
||||
const [showKuntaeErrorCheckDialog, setShowKuntaeErrorCheckDialog] = useState(false);
|
||||
const [showFavoriteDialog, setShowFavoriteDialog] = useState(false);
|
||||
const [userLevel, setUserLevel] = useState<number>(0);
|
||||
const [userCode, setUserCode] = useState<string>('');
|
||||
|
||||
// 사용자 정보 로드
|
||||
useEffect(() => {
|
||||
const loadUserInfo = async () => {
|
||||
try {
|
||||
const loginStatus = await comms.checkLoginStatus();
|
||||
console.log('Login Status:', loginStatus);
|
||||
if (loginStatus.Success && loginStatus.IsLoggedIn && loginStatus.User) {
|
||||
const user = loginStatus.User as { Level?: number; Id?: string };
|
||||
setUserLevel(user.Level || 0);
|
||||
setUserCode(user.Id || '');
|
||||
console.log('userLevel:', user.Level, 'userCode:', user.Id);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('사용자 정보 로드 오류:', error);
|
||||
}
|
||||
};
|
||||
loadUserInfo();
|
||||
}, []);
|
||||
|
||||
const handleAction = (action: string) => {
|
||||
if (action === 'userInfo') {
|
||||
@@ -485,7 +528,7 @@ export function Header(_props: HeaderProps) {
|
||||
{/* Desktop Navigation - Right */}
|
||||
<nav className="hidden lg:flex items-center space-x-1">
|
||||
{/* 드롭다운 메뉴들 (공용정보) */}
|
||||
{dropdownMenus.map((menu) => (
|
||||
{getDropdownMenus(userLevel, userCode).map((menu) => (
|
||||
<DropdownNavMenu key={menu.label} menu={menu} onAction={handleAction} />
|
||||
))}
|
||||
|
||||
@@ -574,7 +617,7 @@ export function Header(_props: HeaderProps) {
|
||||
<div className="border-t border-white/10 my-2" />
|
||||
|
||||
{/* 우측 드롭다운 메뉴들 (공용정보) */}
|
||||
{dropdownMenus.map((menu) => (
|
||||
{getDropdownMenus(userLevel, userCode).map((menu) => (
|
||||
<MobileDropdownMenu
|
||||
key={menu.label}
|
||||
menu={menu}
|
||||
|
||||
Reference in New Issue
Block a user