diff --git a/components/orgchart/OrgChartNode.tsx b/components/orgchart/OrgChartNode.tsx index c77f72d..9d0bb0b 100644 --- a/components/orgchart/OrgChartNode.tsx +++ b/components/orgchart/OrgChartNode.tsx @@ -5,6 +5,7 @@ import { Building2, ChevronDown, Plus, Trash2, UserRound } from "lucide-react"; import Link from "next/link"; import { memo } from "react"; import { Avatar } from "@/components/ui/Avatar"; +import type { OrgUnitType } from "@/lib/org-art"; import { NODE_DIMENSIONS } from "./graphLayout"; import type { ChartNode, ChartNodeKind } from "./types"; @@ -37,6 +38,26 @@ const KIND_ACCENT: Record = { vacancy: "bg-accent-500", }; +// Einheiten tragen statt der Farbe ihrer Knotenart die Farbe ihrer Art, von +// dunkel nach hell absteigend, dazu die Art als Etikett am oberen Rand. Die +// Farbe trägt beim Herauszoomen, das Etikett beim Lesen — und für alle, die +// Farben nicht unterscheiden. +const ART_ACCENT: Record = { + Gesellschaft: "bg-brand-700", + Vorstandsbereich: "bg-brand-500", + Bereich: "bg-info-text", + Abteilung: "bg-purple-text", + Team: "bg-ink-muted", +}; + +const ART_ETIKETT: Record = { + Gesellschaft: "border-brand-700 bg-brand-700 text-white", + Vorstandsbereich: "border-brand-500 bg-brand-500 text-white", + Bereich: "border-info-text bg-info-bg text-info-text", + Abteilung: "border-purple-text bg-purple-bg text-purple-text", + Team: "border-border-strong bg-white text-ink-muted", +}; + const KIND_SHELL: Record = { person: "border-border bg-white", role: "border-border bg-white", @@ -48,7 +69,7 @@ const KIND_SHELL: Record = { // required, not just tidy, to keep that smooth at a few hundred nodes. export const OrgChartNode = memo(function OrgChartNode({ id, data }: NodeProps) { const { chartNode, expanded, hasChildren, childCount, onToggle, onAddUnit, onDeleteUnit, onSelectUnit } = data; - const { kind, label, sublabel, avatar, href, vacant, totalReports, absent, coveredBy, coveringFor, unitId } = chartNode; + const { kind, label, sublabel, avatar, href, vacant, totalReports, absent, coveredBy, coveringFor, unitId, unitType } = chartNode; const isMatch = chartNode.matched ?? false; const { width, height } = NODE_DIMENSIONS[kind]; @@ -157,7 +178,14 @@ export const OrgChartNode = memo(function OrgChartNode({ id, data }: NodeProps + + {unitType && ( + + {unitType} + + )} {href ? ( diff --git a/components/orgchart/PositionTree.tsx b/components/orgchart/PositionTree.tsx index 79ebeeb..d55899e 100644 --- a/components/orgchart/PositionTree.tsx +++ b/components/orgchart/PositionTree.tsx @@ -375,6 +375,7 @@ export function buildUnitTree(units: OrgUnitNode[], employees: OrgEmployee[], va id: key, kind: "role", unitId: unit.id, + unitType: unit.unit_type, label: `${unit.org_number} · ${unit.name}`, // Die Gesellschaft bleibt ohne Vermerk: sie wird nicht geführt, sondern // ist das Ganze. „Leitung vakant" läse sich dort wie eine offene Stelle, diff --git a/components/orgchart/types.ts b/components/orgchart/types.ts index 9f21a17..f1aca42 100644 --- a/components/orgchart/types.ts +++ b/components/orgchart/types.ts @@ -83,5 +83,7 @@ export type ChartNode = { * wäre die ID plötzlich ein Datenformat und nicht mehr nur ein Schlüssel. */ unitId?: string; + /** Die Art der Einheit, nur zusammen mit unitId — bestimmt Farbe und Etikett der Karte. */ + unitType?: OrgUnitType; children: ChartNode[]; };