Files
alpenwerk-hr/components/employees/tabs/StammdatenTab.tsx
Raphael Müllner f95561e594
Some checks failed
CI / Migrationen auf leerer Datenbank (push) Has been cancelled
CI / Ausrollen (push) Has been cancelled
CI / Lint, Typen, Tests, Build (push) Has been cancelled
Kommentare und Texte fuer die Uebergabe durchgesehen; Entra-Einrichtung in der Installationsanleitung
- Kommentare im Praesens statt Entwicklungsgeschichte, ohne Vorfaelle,
  ohne flapsige Wendungen; Verweise auf Migrationsnummern aus Komponenten
  entfernt; in Migrationen nur Kommentarzeilen, alle Kopien gleich
  (leere Datenbank: 156 Migrationen, Rauchtests gruen)
- app/icon.svg ohne eingebettete Herkunfts-Metadaten
- Oberflaeche: keine Emojis in Notizen, Text im Audit-Detail, No Show im
  Offboarding sachlich
- Beispieladressen in Tests auf @firma.example
- Installationsanleitung: Abschnitt App in Entra ID einrichten
2026-10-29 19:21:09 +01:00

104 lines
4.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { AngehoerigeSection } from "@/components/employees/AngehoerigeSection";
import { NotfallkontaktSection } from "@/components/employees/NotfallkontaktSection";
import type { Notfallkontakt } from "@/components/employees/NotfallkontaktModal";
import { hrName, useHrBenutzer } from "@/components/shell/HrBenutzerContext";
import { teilzeitvarianteText } from "@/lib/absence";
import { brauchtAufenthaltstitel } from "@/lib/countries";
import { fmtAge, fmtDate } from "@/lib/format";
import { geschlechtLabel } from "@/lib/geschlecht";
import type { Database } from "@/lib/types";
type EmployeeRow = Database["public"]["Tables"]["employees"]["Row"];
type Location = Database["public"]["Tables"]["locations"]["Row"];
type Dependent = Database["public"]["Tables"]["employee_dependents"]["Row"];
export function StammdatenTab({
employee,
location,
dependents,
notfallkontakte,
}: {
employee: EmployeeRow;
location?: Location;
dependents: Dependent[];
notfallkontakte: Notfallkontakt[];
}) {
// The title columns may be undefined rather than the empty array the column
// default implies; treat both as "no titles".
const hrBenutzer = useHrBenutzer();
const prefixe = employee.title_prefix ?? [];
const suffixe = employee.title_suffix ?? [];
// Feld für Feld dieselbe Liste wie im Abschnitt „Person" von „Daten
// ändern", in derselben Reihenfolge.
//
// Nichts wird zusammengefasst: Titel, Adresse, Postleitzahl, Ort, Vor- und
// Nachname stehen je für sich. Wer eine Angabe prüfen will, soll dafür
// nicht den Änderungsdialog öffnen müssen und dann schon in einem Formular
// stehen. Was sich ändern lässt, soll sich auch ansehen lassen.
const rows: [string, string][] = [
["Personalnummer", String(employee.personnel_number)],
["Vorname", employee.first_name],
["Nachname", employee.last_name],
["Titel (vorangestellt)", prefixe.length > 0 ? prefixe.join(", ") : "–"],
["Titel (nachgestellt)", suffixe.length > 0 ? suffixe.join(", ") : "–"],
["Geschlecht", geschlechtLabel(employee.gender)],
["Geburtsdatum", employee.birth_date ? `${fmtDate(employee.birth_date)} (${fmtAge(employee.birth_date)} Jahre)` : "–"],
["SV-Nummer", employee.sv_nummer ?? "–"],
["Staatsbürgerschaft", employee.nationality],
// Nur, wo er verlangt ist. Bei einer österreichischen Staatsbürger-
// schaft wäre die Zeile „Aufenthaltstitel: Nein" keine Auskunft,
// sondern eine Frage, die sich nicht stellt.
...(brauchtAufenthaltstitel(employee.nationality)
? ([
[
"Aufenthaltstitel",
employee.hat_aufenthaltstitel
? employee.aufenthaltstitel_bis
? `Ja, bis ${fmtDate(employee.aufenthaltstitel_bis)}`
: "Ja (unbefristet oder nicht erfasst)"
: "Nein",
],
] as [string, string][])
: []),
["Erlernter Beruf", employee.erlernter_beruf ?? "–"],
[
"Übernahme Leiharbeitskraft",
employee.ist_uebernahme_leiharbeit ? employee.uebernahme_leiharbeit_text || "Ja" : "Nein",
],
["Adresse", employee.address ?? "–"],
["Postleitzahl", employee.postal_code ?? "–"],
["Ort", employee.city ?? "–"],
["Land", employee.address_country ?? "–"],
["Private E-Mail", employee.email ?? "–"],
["Firmen-E-Mail", employee.company_email ?? "–"],
["Cornerstone-ID", employee.cornerstone_id ?? "–"],
["Zuständige HR", hrName(hrBenutzer, employee.zustaendige_hr_id)],
["Private Telefonnummer", employee.phone ?? "–"],
// Der Standort ist keine Angabe zur Person, sondern die Betriebsstätte —
// er steht deshalb am Ende und nicht zwischen Adresse und Land, wo man
// ihn für den Wohnort halten könnte.
["Standort", location ? `${location.name} (${location.country})` : "–"],
// Auch hier und nicht nur unter „Vertrag", fachlich so vorgegeben: in
// „Daten ändern" steht das Feld im selben Formular wie die Person, und
// wer es dort sieht, sucht es in der Akte auf diesem Blatt.
["Teilzeitvariante", teilzeitvarianteText(employee)],
];
return (
<div className="flex flex-col gap-6">
<dl className="grid grid-cols-1 gap-x-8 gap-y-4 sm:grid-cols-2 lg:grid-cols-3">
{rows.map(([label, value]) => (
<div key={label}>
<dt className="text-xs font-semibold uppercase tracking-wide text-ink-muted">{label}</dt>
<dd className="mt-1 text-sm text-ink">{value}</dd>
</div>
))}
</dl>
<AngehoerigeSection employeeId={employee.id} dependents={dependents} />
<NotfallkontaktSection employeeId={employee.id} kontakte={notfallkontakte} />
</div>
);
}