'use client' import { useAuthStore } from '@/lib/store/authStore' import { buildTree, type TreeNode } from './Sidebar' function findTrail(nodes: TreeNode[], targetMenuNo: string | null): TreeNode[] { if (!targetMenuNo) return [] for (const node of nodes) { if (node.menuNo === targetMenuNo) return [node] const childTrail = findTrail(node.children, targetMenuNo) if (childTrail.length > 0) return [node, ...childTrail] } return [] } export function Breadcrumb() { const menuList = useAuthStore((s) => s.menuList) const selectedMenuNo = useAuthStore((s) => s.selectedMenuNo) const tree = buildTree(menuList) const trail = findTrail(tree, selectedMenuNo) if (trail.length === 0) return null const current = trail[trail.length - 1] return (

{current.menuNm}

{trail.length > 1 && ( <> | )}
) }