@
All checks were successful
CI / Lint, Typen, Tests, Build (push) Successful in 11m12s
CI / Migrationen auf leerer Datenbank (push) Successful in 10m6s

Name every draft, and put Vertrag before Angehoerige

Two things the dashboard and the hire wizard were getting wrong.

The drafts card named the author only on other people's drafts. With
foreign and own rows side by side that reads as an inconsistency, not as
information: the eye has to work out that a missing name means "mine".
Now every row says it, "von mir" on the own ones -- the same wording the
notes in the bell already use.

In the wizard, Angehoerige stood before Vertrag. What a contract is made
of -- entry date, working days, a fixed term -- is on paper before the
conversation happens; relatives the person brings along, often on the
first day. The optional step came before the one the hire rests on.

Swapping them meant touching the part that would have broken silently:
the per-step validation was a positional list that had to line up with
STEP_LABELS by hand. Reordered labels alone would have left the checks
where they were -- "Weiter" on Vertrag would have validated the
relatives and waved an empty entry date through, until the database
refused it at the end. The checks are keyed by step name now, so they
travel with the step.

Drafts saved before this land on the step number they stored, which now
points at a different page. Nothing is lost -- the payload carries every
field -- but somebody resuming an older draft may open on Vertrag where
they left Angehoerige.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@
This commit is contained in:
2026-09-10 16:35:20 +02:00
parent eeaf210e78
commit 2838919e42
6 changed files with 186 additions and 32 deletions

View File

@@ -17,7 +17,12 @@ import { StepSummary } from "./StepSummary";
import { StepVertrag } from "./StepVertrag";
import { EMPTY_HIRE_DRAFT, type HireDraftData } from "./types";
const STEP_LABELS = ["Person", "Position", "Angehörige", "Vertrag", "Notfallkontakt", "Zusammenfassung"];
// Vertrag vor Angehörige: was den Vertrag ausmacht — Eintritt, Arbeitstage,
// Befristung — steht auf dem Papier, das vor dem Gespräch da ist. Angehörige
// bringt die Person mit, oft erst am ersten Tag. Bis September 2026 stand es
// andersherum, und der freiwillige Schritt lag vor dem, der die Einstellung
// überhaupt trägt.
const STEP_LABELS = ["Person", "Position", "Vertrag", "Angehörige", "Notfallkontakt", "Zusammenfassung"] as const;
type HireWizardProps = {
open: boolean;
@@ -59,31 +64,41 @@ export function HireWizard({ open, onClose, openPositions, locations, resumeDraf
!requiresAustrianSvnr(locations.find((l) => l.id === draft.locationId)?.country) ||
isValidSvnr(draft.svNummer, draft.birthDate || null);
const stepValid = [
// Am Namen des Schritts, nicht an seiner Nummer.
//
// Vorher war das eine Liste in derselben Reihenfolge wie STEP_LABELS, und
// die beiden mussten stumm zusammenpassen. Beim Vertauschen von Vertrag und
// Angehörige wäre die Prüfung stehengeblieben, wo sie war: „Weiter" im
// Vertrag hätte die Angehörigen geprüft und ein leeres Eintrittsdatum
// durchgelassen — bis die Datenbank es am Ende abweist.
const pruefung: Record<(typeof STEP_LABELS)[number], boolean> = {
// E-Mail gehört zu den Pflichtfeldern, weil die Spalte NOT NULL ist. Ohne
// die Prüfung hier bricht erst die Datenbank ab — am Ende des vierten
// Schritts, nach allen Eingaben.
// die Prüfung hier bricht erst die Datenbank ab — nach allen Eingaben.
// Die private E-Mail-Adresse steht bewusst nicht mehr darunter: sie ist
// freiwillig, seit die Spalte NULL zulässt.
Boolean(draft.personnelNumber.trim() && draft.firstName && draft.lastName && draft.birthDate && draft.locationId) &&
svNummerOk,
Boolean(draft.positionId && draft.besetzung),
Person:
Boolean(
draft.personnelNumber.trim() && draft.firstName && draft.lastName && draft.birthDate && draft.locationId
) && svNummerOk,
Position: Boolean(draft.positionId && draft.besetzung),
Vertrag: Boolean(draft.entryDate && draft.workDays.length > 0),
// Angehörige: freiwillig — aber eine begonnene Zeile muss vollständig
// sein, sonst scheitert sie erst nach dem Anlegen der Person, und die
// steht dann schon in der Datenbank.
draft.angehoerige.every(
Angehörige: draft.angehoerige.every(
(a) =>
a.firstName.trim() &&
a.lastName.trim() &&
a.birthDate &&
(!a.svNummer.trim() || isValidSvnr(a.svNummer, a.birthDate || null))
),
Boolean(draft.entryDate && draft.workDays.length > 0),
// Notfallkontakt: freiwillig, aber Name und Nummer nur gemeinsam — die
// Datenbank weist eines ohne das andere ab (chk_emergency_contact).
Boolean(draft.emergencyContactName.trim()) === Boolean(draft.emergencyContactPhone.trim()),
true,
][step];
Notfallkontakt:
Boolean(draft.emergencyContactName.trim()) === Boolean(draft.emergencyContactPhone.trim()),
Zusammenfassung: true,
};
const stepValid = pruefung[STEP_LABELS[step]];
/** Der letzte Schritt; von hier wird angelegt statt weitergeblättert. */
const letzterSchritt = STEP_LABELS.length - 1;
@@ -242,8 +257,8 @@ export function HireWizard({ open, onClose, openPositions, locations, resumeDraf
{step === 0 && <StepPerson draft={draft} update={update} locations={locations} />}
{step === 1 && <StepPosition draft={draft} update={update} openPositions={openPositions} />}
{step === 2 && <StepAngehoerige draft={draft} update={update} />}
{step === 3 && <StepVertrag draft={draft} update={update} />}
{step === 2 && <StepVertrag draft={draft} update={update} />}
{step === 3 && <StepAngehoerige draft={draft} update={update} />}
{step === 4 && <StepNotfallkontakt draft={draft} update={update} />}
{step === 5 && <StepSummary draft={draft} selectedPosition={selectedPosition} locations={locations} />}
</Modal>