Files
alpenwerk-hr/components/orgchart/OrgChartClient.tsx
Raphael Müllner b47dec6387 Übergabestand 2026-10-14
Alpenwerk HR — HR-Stammdatenverwaltung

Mitarbeiter:innen, Organisationsstruktur, Planstellen, Eintritt, Austritt,
Versetzung, Beförderung, Karenz, On- und Offboarding, Berichte, Exporte,
Massenimport und ein lückenloser Nachweis jeder Änderung.

Next.js 16, React 19 und TypeScript; PostgreSQL über Kysely; Anmeldung
ausschliesslich über Microsoft Entra ID. Die Fachlogik liegt in der
Datenbank, die Zugriffsschranke ist Row Level Security.

Betrieb auf Windows Server: siehe deploy/windows/README.md.
Sicherheitskonzept: docs/sicherheitskonzept.md.
2026-10-14 10:12:22 +02:00

71 lines
2.4 KiB
TypeScript

"use client";
import { Printer } from "lucide-react";
import Link from "next/link";
import { SegmentedControl } from "@/components/ui/SegmentedControl";
import { useGemerktesWort } from "./ansicht-merken";
import { AsOfPicker } from "./AsOfPicker";
import { EmployeeTree } from "./EmployeeTree";
import { PositionTree } from "./PositionTree";
import type { OrgEmployee, OrgUnitNode, OrgVacancy } from "./types";
type View = "ma" | "pos";
const VIEWS: readonly View[] = ["ma", "pos"] as const;
type OrgChartClientProps = {
employees: OrgEmployee[];
units: OrgUnitNode[];
vacancies: OrgVacancy[];
asOf: string;
today: string;
projectedCount: number;
historyStartsAt: string | null;
/** Arrived via "Im Organigramm anzeigen" — unfold and centre this person. */
focusId: string | null;
};
export function OrgChartClient({
employees,
units,
vacancies,
asOf,
today,
projectedCount,
historyStartsAt,
focusId,
}: OrgChartClientProps) {
// Gemerkt, nicht neu gesetzt: wer aus der Organisationssicht eine Person
// öffnet, landete sonst beim Zurückgehen wieder auf der Mitarbeitersicht.
const [view, setView] = useGemerktesWort<View>("alpenwerk.orgchart.sicht", "ma", VIEWS);
return (
<div className="flex flex-col gap-4">
<div className="flex flex-wrap items-center justify-between gap-3">
<SegmentedControl<View>
value={view}
onChange={setView}
options={[
{ value: "ma", label: "Mitarbeiter" },
{ value: "pos", label: "Organisation" },
]}
/>
{/* Der Stichtag wandert mit: wer eine vergangene Struktur ansieht,
druckt sie auch. */}
<Link
href={asOf === today ? "/orgchart/print" : `/orgchart/print?asOf=${asOf}`}
className="inline-flex items-center gap-2 rounded-md border border-border px-3 py-2 text-sm font-semibold text-ink hover:bg-brand-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-500"
>
<Printer className="h-4 w-4" />
Als PDF
</Link>
</div>
<AsOfPicker asOf={asOf} today={today} projectedCount={projectedCount} historyStartsAt={historyStartsAt} />
{view === "ma" && <EmployeeTree employees={employees} focusId={focusId} />}
{view === "pos" && <PositionTree employees={employees} units={units} vacancies={vacancies} />}
</div>
);
}