Ü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.
This commit is contained in:
112
components/audit/AuditDetail.tsx
Normal file
112
components/audit/AuditDetail.tsx
Normal file
@@ -0,0 +1,112 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useState } from "react";
|
||||
import { AenderungsTabelle } from "@/components/ui/AenderungsTabelle";
|
||||
import { SlideOver } from "@/components/ui/SlideOver";
|
||||
import { actionBadgeStyle } from "@/lib/colors";
|
||||
import type { AuditChange } from "@/lib/types";
|
||||
|
||||
// Eine Protokollzeile zum Aufklappen.
|
||||
//
|
||||
// Die Liste zeigt, *dass* etwas geändert wurde; hier steht, *was*. Beides in
|
||||
// der Tabelle unterzubringen ginge nicht — bei sieben geänderten Feldern
|
||||
// wäre die Zeile höher als der Bildschirm.
|
||||
|
||||
export type AuditEintrag = {
|
||||
id: string;
|
||||
occurred_at: string;
|
||||
actor_name: string;
|
||||
action: string;
|
||||
target_label: string;
|
||||
target_employee_id: string | null;
|
||||
details: string | null;
|
||||
changes: AuditChange[] | null;
|
||||
};
|
||||
|
||||
const zeitFormat = new Intl.DateTimeFormat("de-AT", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
timeZone: "Europe/Vienna",
|
||||
});
|
||||
|
||||
export function AuditDetail({ eintrag }: { eintrag: AuditEintrag }) {
|
||||
const [offen, setOffen] = useState(false);
|
||||
const anzahl = eintrag.changes?.length ?? 0;
|
||||
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setOffen(true)}
|
||||
aria-haspopup="dialog"
|
||||
className="w-full rounded px-2 py-1 text-left text-ink-muted hover:bg-brand-50 hover:text-ink
|
||||
focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-500"
|
||||
>
|
||||
<span>{eintrag.details ?? "–"}</span>
|
||||
{anzahl > 0 && (
|
||||
<span className="ml-2 whitespace-nowrap rounded-full bg-accent-100 px-2 py-0.5 text-[11px] font-semibold text-brand-700">
|
||||
{anzahl} {anzahl === 1 ? "Feld" : "Felder"}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
|
||||
<SlideOver
|
||||
open={offen}
|
||||
onClose={() => setOffen(false)}
|
||||
title={eintrag.target_label}
|
||||
subtitle={`${eintrag.action} · ${zeitFormat.format(new Date(eintrag.occurred_at))}`}
|
||||
>
|
||||
<dl className="grid grid-cols-[auto_1fr] gap-x-6 gap-y-2 text-sm">
|
||||
<dt className="font-semibold text-ink-muted">Aktion</dt>
|
||||
<dd>
|
||||
<span className={`rounded-full px-2 py-0.5 text-[11px] font-semibold ${actionBadgeStyle(eintrag.action)}`}>
|
||||
{eintrag.action}
|
||||
</span>
|
||||
</dd>
|
||||
<dt className="font-semibold text-ink-muted">Benutzer:in</dt>
|
||||
<dd className="text-ink">{eintrag.actor_name}</dd>
|
||||
<dt className="font-semibold text-ink-muted">Zeitpunkt</dt>
|
||||
<dd className="tabular-nums text-ink">{zeitFormat.format(new Date(eintrag.occurred_at))}</dd>
|
||||
{eintrag.target_employee_id && (
|
||||
<>
|
||||
<dt className="font-semibold text-ink-muted">Objekt</dt>
|
||||
<dd>
|
||||
<Link
|
||||
href={`/employees/${eintrag.target_employee_id}`}
|
||||
className="rounded font-semibold text-brand-700 hover:underline
|
||||
focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-500"
|
||||
>
|
||||
{eintrag.target_label}
|
||||
</Link>
|
||||
</dd>
|
||||
</>
|
||||
)}
|
||||
</dl>
|
||||
|
||||
{eintrag.details && (
|
||||
<p className="mt-5 rounded-md bg-surface px-3 py-2 text-sm text-ink-body">{eintrag.details}</p>
|
||||
)}
|
||||
|
||||
<h3 className="mt-6 text-sm font-bold text-ink">Geänderte Felder</h3>
|
||||
{anzahl > 0 ? (
|
||||
<div className="mt-2">
|
||||
<AenderungsTabelle changes={eintrag.changes!} />
|
||||
</div>
|
||||
) : (
|
||||
// Kein Aufzählungszeichen für „nichts da“: der Grund ist wichtig,
|
||||
// damit niemand einen Fehler vermutet.
|
||||
<p className="mt-2 max-w-prose text-sm text-ink-muted">
|
||||
Für diesen Eintrag liegen keine Feldwerte vor. Vorgänge wie Eintritt, Austritt oder Import erfassen keine
|
||||
Einzelfelder — und Einträge von vor der Erweiterung des Protokolls haben nur die Feldnamen behalten, nicht
|
||||
die Werte. Nachliefern lässt sich das nicht.
|
||||
</p>
|
||||
)}
|
||||
</SlideOver>
|
||||
</>
|
||||
);
|
||||
}
|
||||
77
components/audit/AuditFilters.tsx
Normal file
77
components/audit/AuditFilters.tsx
Normal file
@@ -0,0 +1,77 @@
|
||||
"use client";
|
||||
|
||||
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
||||
import { useEffect, useState } from "react";
|
||||
import { FILTER_SELECT_CLASS } from "@/components/ui/Field";
|
||||
import { SearchInput } from "@/components/ui/SearchInput";
|
||||
|
||||
// The value is the string stored in audit_log.action and must not change;
|
||||
// only what the user reads does — 'Karenz' is displayed as
|
||||
// "Langzeitabwesenheit" (see lib/absence.ts).
|
||||
const ACTIONS: { value: string; label: string }[] = [
|
||||
{ value: "Neueinstellung", label: "Neueinstellung" },
|
||||
{ value: "Wiedereinstellung", label: "Wiedereinstellung" },
|
||||
{ value: "Rückkehr", label: "Rückkehr aus Langzeitabwesenheit" },
|
||||
{ value: "Austritt", label: "Austritt" },
|
||||
{ value: "Versetzung", label: "Versetzung" },
|
||||
{ value: "Ausschreibung", label: "Ausschreibung" },
|
||||
{ value: "Interne Besetzung", label: "Interne Besetzung" },
|
||||
{ value: "Beförderung", label: "Beförderung" },
|
||||
{ value: "Reorganisation", label: "Reorganisation" },
|
||||
{ value: "Reorganisation rückgängig", label: "Reorganisation rückgängig" },
|
||||
{ value: "Karenz", label: "Langzeitabwesenheit" },
|
||||
{ value: "Vertragsänderung", label: "Vertragsänderung" },
|
||||
{ value: "Stammdatenänderung", label: "Stammdatenänderung" },
|
||||
// „Gehaltsanpassung" steht nicht zur Auswahl: das Gehalt gehört nicht zum
|
||||
// Funktionsumfang (es wird in Loga geführt), keine Funktion schreibt diese
|
||||
// Art, und ein Filter, der immer leer ausgeht, sieht aus wie ein Fehler.
|
||||
// Der Wert bleibt im Aufzählungstyp, damit vorhandene Einträge dieser Art
|
||||
// lesbar bleiben.
|
||||
];
|
||||
|
||||
export function AuditFilters() {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
const [q, setQ] = useState(searchParams.get("q") ?? "");
|
||||
|
||||
useEffect(() => {
|
||||
const handle = setTimeout(() => {
|
||||
const current = new URLSearchParams(searchParams.toString());
|
||||
if (q) current.set("q", q);
|
||||
else current.delete("q");
|
||||
current.delete("page");
|
||||
const next = current.toString();
|
||||
if (next !== searchParams.toString()) router.push(`${pathname}?${next}`);
|
||||
}, 300);
|
||||
return () => clearTimeout(handle);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [q]);
|
||||
|
||||
function updateParam(key: string, value: string) {
|
||||
const params = new URLSearchParams(searchParams.toString());
|
||||
if (value) params.set(key, value);
|
||||
else params.delete(key);
|
||||
params.delete("page");
|
||||
router.push(`${pathname}?${params.toString()}`);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<SearchInput label="Audit-Log durchsuchen" placeholder="Objekt, Details, Benutzer:in…" value={q} onChange={setQ} />
|
||||
<select
|
||||
aria-label="Nach Aktion filtern"
|
||||
defaultValue={searchParams.get("action") ?? ""}
|
||||
onChange={(e) => updateParam("action", e.target.value)}
|
||||
className={FILTER_SELECT_CLASS}
|
||||
>
|
||||
<option value="">Alle Aktionen</option>
|
||||
{ACTIONS.map((a) => (
|
||||
<option key={a.value} value={a.value}>
|
||||
{a.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
43
components/audit/AuditTabs.tsx
Normal file
43
components/audit/AuditTabs.tsx
Normal file
@@ -0,0 +1,43 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
// Zwei Seiten, eine Frage: was ist mit den Daten geschehen. Das Log beantwortet
|
||||
// sie rückwärts, „Geplante Änderungen" vorwärts — deshalb stehen sie
|
||||
// nebeneinander und nicht an zwei Stellen der Seitenleiste.
|
||||
//
|
||||
// Als Navigation ausgezeichnet und nicht als tablist: hinter den beiden
|
||||
// Einträgen stehen zwei Adressen, keine zwei Zustände einer Seite. Ein
|
||||
// Screenreader soll „Link, aktuelle Seite" sagen und nicht „Registerkarte,
|
||||
// ausgewählt" — sonst verspricht er ein Umschalten ohne Seitenwechsel.
|
||||
const TABS = [
|
||||
{ href: "/audit", label: "Audit-Log" },
|
||||
{ href: "/audit/geplant", label: "Geplante Änderungen" },
|
||||
] as const;
|
||||
|
||||
export function AuditTabs() {
|
||||
const pathname = usePathname();
|
||||
|
||||
return (
|
||||
<nav aria-label="Protokolle" className="flex gap-1 overflow-x-auto border-b border-border">
|
||||
{TABS.map((t) => {
|
||||
// Exakter Vergleich und kein startsWith: „/audit" ist Präfix von
|
||||
// „/audit/geplant", beide Einträge wären sonst gleichzeitig aktiv.
|
||||
const aktiv = pathname === t.href;
|
||||
return (
|
||||
<Link
|
||||
key={t.href}
|
||||
href={t.href}
|
||||
aria-current={aktiv ? "page" : undefined}
|
||||
className={`whitespace-nowrap border-b-2 px-4 py-2 text-sm font-semibold focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-brand-500 ${
|
||||
aktiv ? "border-brand-500 text-brand-700" : "border-transparent text-ink-muted hover:text-ink"
|
||||
}`}
|
||||
>
|
||||
{t.label}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user