Files
smart-go/web/components/iam/DeptTreeView.tsx
T
2026-04-23 18:58:13 +08:00

24 lines
747 B
TypeScript

'use client';
import type { DeptNode } from '@/lib/api/types/dept';
function DeptNodes({ nodes, depth }: { nodes: DeptNode[]; depth: number }) {
return (
<ul className={depth === 0 ? 'space-y-1' : 'ml-4 mt-1 space-y-1 border-l border-neutral-200 pl-3'}>
{nodes.map((n) => (
<li key={n.id} className="text-sm">
<span className="text-neutral-800">{n.dept_name}</span>
{n.children?.length ? <DeptNodes nodes={n.children} depth={depth + 1} /> : null}
</li>
))}
</ul>
);
}
export function DeptTreeView(props: { tree: DeptNode[] }) {
if (!props.tree.length) {
return <p className="text-sm text-neutral-500"></p>;
}
return <DeptNodes nodes={props.tree} depth={0} />;
}