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.
55 lines
2.0 KiB
TypeScript
55 lines
2.0 KiB
TypeScript
import { Suspense } from "react";
|
|
import { OrgChartClient } from "@/components/orgchart/OrgChartClient";
|
|
import type { OrgUnitNode } from "@/components/orgchart/types";
|
|
import { todayIso } from "@/lib/format";
|
|
import { loadOrgAsOf } from "@/lib/orgchart-data";
|
|
import { parseIsoDateParam } from "@/lib/reports";
|
|
import { currentUserId } from "@/lib/auth/session";
|
|
import { withUser } from "@/lib/db";
|
|
|
|
type SearchParams = { asOf?: string; focus?: string };
|
|
|
|
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
|
|
export default async function OrgChartPage({ searchParams }: { searchParams: Promise<SearchParams> }) {
|
|
const params = await searchParams;
|
|
const today = todayIso();
|
|
const asOf = parseIsoDateParam(params.asOf) ?? today;
|
|
// Only ever used to match against ids already on the page, but validated
|
|
// so a junk value can't reach the client as an arbitrary string.
|
|
const focusId = params.focus && UUID.test(params.focus) ? params.focus : null;
|
|
|
|
const { org, units } = await withUser(await currentUserId(), async (tx) => {
|
|
const [org, units] = await Promise.all([
|
|
loadOrgAsOf(tx, asOf),
|
|
tx
|
|
.selectFrom("org_units")
|
|
// valid_from/valid_to nur hier: die Angaben zur Einheit zeigen sie,
|
|
// der Druck braucht sie nicht.
|
|
.select(["id", "org_number", "name", "parent_id", "unit_type", "valid_from", "valid_to"])
|
|
// Zum Stichtag — sonst zeigt die Struktursicht zum 01.01.2020
|
|
// Einheiten, die es an diesem Tag nicht gab.
|
|
.where("valid_from", "<=", asOf)
|
|
.where((eb) => eb.or([eb("valid_to", "is", null), eb("valid_to", ">", asOf)]))
|
|
.orderBy("org_number")
|
|
.execute(),
|
|
]);
|
|
return { org, units };
|
|
});
|
|
|
|
return (
|
|
<Suspense>
|
|
<OrgChartClient
|
|
employees={org.employees}
|
|
units={units as OrgUnitNode[]}
|
|
vacancies={org.vacancies}
|
|
asOf={asOf}
|
|
today={today}
|
|
projectedCount={org.projectedCount}
|
|
historyStartsAt={org.historyStartsAt}
|
|
focusId={focusId}
|
|
/>
|
|
</Suspense>
|
|
);
|
|
}
|