"use client"; import { useState } from "react"; import { cn } from "@/lib/utils"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Badge } from "@/components/ui/badge"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Search, FileQuestion, ArrowRight, Pencil, Link } from "lucide-react"; import type { MenuTreeNode } from "../types"; interface UnassignedMenusPanelProps { menus: MenuTreeNode[]; onAssign: (menuId: number, groupId: number) => void; onActivateAsTopLevel: (menuId: number) => void; onEdit: (menu: MenuTreeNode) => void; availableGroups: { id: number; title: string; parentTitle?: string }[]; } export function UnassignedMenusPanel({ menus, onAssign, onActivateAsTopLevel, onEdit, availableGroups, }: UnassignedMenusPanelProps) { const [searchTerm, setSearchTerm] = useState(""); const [selectedMenu, setSelectedMenu] = useState(null); const filteredMenus = menus.filter( (menu) => menu.titleKo.toLowerCase().includes(searchTerm.toLowerCase()) || menu.menuPath?.toLowerCase().includes(searchTerm.toLowerCase()) ); return ( Unassigned Menus ({menus.length}) Assign to a group or activate as a top-level link. {/* Search */}
setSearchTerm(e.target.value)} className="pl-8" />
{/* Menu List */}
{filteredMenus.length === 0 ? (

{searchTerm ? "No results found." : "No unassigned menus."}

) : ( filteredMenus.map((menu) => (
{menu.titleKo} Inactive

{menu.menuPath}

{/* Group Selection (expanded) */} {selectedMenu === menu.id ? (
{/* Activate as Top-Level */}

Activate as top-level link:

{/* Assign to Group */} {availableGroups.length > 0 && (

Or assign to group:

{availableGroups.map((group) => ( ))}
)}
) : ( )}
)) )}
); }