import { useState } from "react";
import { Link, NavLink, useLocation } from "react-router-dom";
import { useAuthStore } from "@/stores/authStore";
/** 단일 메뉴 항목 */
interface NavItem {
to: string;
icon: string;
label: string;
}
/** 드롭다운 메뉴 그룹 */
interface NavGroup {
icon: string;
label: string;
children: { to: string; label: string }[];
}
type NavEntry =
| { type: "item"; item: NavItem }
| { type: "group"; group: NavGroup }
| { type: "separator" };
/** 네비게이션 메뉴 정의 (가이드라인 기준) */
const navEntries: NavEntry[] = [
{ type: "item", item: { to: "/dashboard", icon: "dashboard", label: "대시보드" } },
{ type: "item", item: { to: "/services", icon: "manage_accounts", label: "서비스 관리" } },
{ type: "item", item: { to: "/messages", icon: "mail", label: "메시지 관리" } },
{ type: "item", item: { to: "/devices", icon: "devices", label: "기기 관리" } },
{
type: "group",
group: {
icon: "send",
label: "발송 관리",
children: [
{ to: "/statistics", label: "발송 통계" },
{ to: "/statistics/history", label: "발송 이력" },
],
},
},
{ type: "item", item: { to: "/tags", icon: "sell", label: "태그 관리" } },
{ type: "separator" },
{
type: "group",
group: {
icon: "settings",
label: "설정",
children: [
{ to: "/settings/notifications", label: "알림" },
{ to: "/settings", label: "마이 페이지" },
],
},
},
];
/** 단일 메뉴 아이템 */
function SidebarItem({ item }: { item: NavItem }) {
const location = useLocation();
const isActive = location.pathname === item.to || location.pathname.startsWith(item.to + "/");
return (