Files
alpenwerk-hr/components/orgchart/OrgChartClient.tsx
Andrei Laas 6a7106c95d Alpenwerk HR -- interne HR-Stammdatenverwaltung
Mitarbeiter:innen, Organisationsstruktur, Planstellen, Eintritt, Austritt,
Versetzung, Befoerderung, Karenz, On- und Offboarding, Berichte, Massenimport
und ein lueckenloser Nachweis jeder Aenderung.

Next.js 16 mit React 19 und TypeScript, PostgreSQL 17 ueber Kysely, Anmeldung
ueber Microsoft Entra ID. Die Fachlogik liegt in der Datenbank: rund dreissig
PL/pgSQL-Funktionen fuehren eine Aenderung, ihren Historieneintrag und ihren
Protokolleintrag in einer Transaktion aus. Die Zugriffsschranke ist Row Level
Security, nicht die Oberflaeche.

Betrieb auf Windows Server ohne Docker: ein fertiges Paket, ein Windows-Dienst,
der IIS als HTTPS-Vorschaltung und zwei geplante Aufgaben. Siehe
deploy/windows/README.md.
2026-10-13 20:11:18 +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 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>
);
}