feat: Add menu icon support in menu management

- Enhanced the menu management functionality by adding a new `menu_icon` field in the database schema, allowing for the storage of menu icons.
- Updated the `saveMenu` and `updateMenu` functions in the admin controller to handle the new `menu_icon` field during menu creation and updates.
- Modified the `AdminService` to include `MENU_ICON` in various queries, ensuring that the icon data is retrieved and processed correctly.
- Integrated the `MenuIconPicker` component in the frontend to allow users to select and display menu icons in the `MenuFormModal`.
- Updated the sidebar and layout components to utilize the new icon data, enhancing the visual representation of menus across the application.
This commit is contained in:
kjs
2026-03-03 15:42:30 +09:00
parent f697e1e897
commit ce8b4ed688
9 changed files with 620 additions and 25 deletions

View File

@@ -2,6 +2,7 @@ import { ChevronDown, ChevronRight, Home, FileText, Users, BarChart3, Cog, GitBr
import { cn } from "@/lib/utils";
import { MenuItem } from "@/types/menu";
import { MENU_ICONS, MESSAGES } from "@/constants/layout";
import { getIconComponent } from "@/components/admin/MenuIconPicker";
interface MainSidebarProps {
menuList: MenuItem[];
@@ -11,9 +12,14 @@ interface MainSidebarProps {
}
/**
* 메뉴 아이콘 선택 함수
* 메뉴 아이콘 선택 함수 (DB 아이콘 우선, 없으면 키워드 기반 fallback)
*/
const getMenuIcon = (menuName: string) => {
const getMenuIcon = (menuName: string, dbIconName?: string | null) => {
if (dbIconName) {
const DbIcon = getIconComponent(dbIconName);
if (DbIcon) return <DbIcon className="h-4 w-4" />;
}
if (MENU_ICONS.HOME.some((keyword) => menuName.includes(keyword))) {
return <Home className="h-4 w-4" />;
}
@@ -57,7 +63,7 @@ export function MainSidebar({ menuList, expandedMenus, onMenuClick, className =
)}
>
<div className="flex items-center gap-2">
{getMenuIcon(menu.MENU_NAME_KOR || menu.menuNameKor || "")}
{getMenuIcon(menu.MENU_NAME_KOR || menu.menuNameKor || "", menu.MENU_ICON || menu.menu_icon)}
<span>{menu.MENU_NAME_KOR || menu.menuNameKor || "메뉴"}</span>
</div>
{hasChildren && (isExpanded ? <ChevronDown className="h-4 w-4" /> : <ChevronRight className="h-4 w-4" />)}