Files
helix/web/src/utils/department-utils/index.ts
T
siujamo 965b92b47d chore: restructure into monorepo and add open-source documentation
- Rename helix-server -> server and helix-web -> web
- Remove helix-api (bruno collection and docs site)
- Merge per-module .gitignore files into the root .gitignore
- Add README, AGENTS, CONTRIBUTING and MIT LICENCE
- Add full-stack docker-compose (postgres, redis, server, web via Caddy)
  with web Dockerfile, Caddyfile and Compose server config
- Keep the Gradle wrapper jar tracked after the .gitignore merge
- Copy gradle.properties into the server Docker build image
2026-09-01 10:48:45 +08:00

29 lines
750 B
TypeScript

import { type TreeDataNode } from "antd"
import type { TreeNode } from "@/types/tree"
import type { Department } from "@/types/entity"
export function transformDepartmentData(departments: TreeNode<Department>[]): TreeDataNode[] {
if (!departments || departments.length === 0) {
return []
}
return departments
.sort((a, b) => a.item.sort - b.item.sort)
.map((node) => {
const { item, children } = node
const hasChildren = children && children.length > 0
const treeItem: TreeDataNode = {
key: item.id,
title: item.name,
}
if (hasChildren) {
// Append children
return { ...treeItem, children: transformDepartmentData(children) }
}
return treeItem
})
}