- 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
29 lines
750 B
TypeScript
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
|
|
})
|
|
}
|