Mehrere Notfallkontakte, Planstelle nicht vor ihrer Einheit, Anstehend fuehrt in die Historie, Uebernahme, Meine Notizen
- Notfallkontakte: eigene Tabelle employee_emergency_contacts (Migration 20261019160000), beliebig viele je Person, angelegt, geaendert und entfernt wie Angehoerige (add_/update_/delete_emergency_contact, mit Historie und Protokoll). Bestand uebernommen. Verhaeltnis-Liste wie bei den Angehoerigen (Ehepartner, Lebenspartner, Kind, Sonstige mit Freitext). Neueinstellung, Wiedereintritt, Import und Mitarbeiterexport schreiben und lesen die Tabelle. - Planstelle beginnt nicht vor und nicht nach dem Bestehen ihrer Organisationseinheit: Ausloeser an om_positions (Migration 20261019150000), gilt fuer Anlegen, Aendern und Klonen. - Anstehend auf der Uebersicht: Klick oeffnet die Akte im Reiter Historie, bei einer Wiedervorlage im Reiter HR-Notizen (?tab=). - Uebernahme: Vertrag zeigt Besetzungsart und "Uebernahme Ja/Nein" aus der Historie; die Kachel Eintritte (YTD) zaehlt Uebernahmen mit. - Glocke: "Meine Notizen" schaltet bei hinzugewaehlten Kollegen auf nur die eigenen Notizen um. Rauchtest Schritt 18. Geprueft: lint, tsc, types:check, 921 Tests, Waechter
This commit is contained in:
@@ -91,8 +91,11 @@ export function AnstehendListe({
|
||||
const ueberfaellig = item.date < today;
|
||||
return (
|
||||
<li key={`${item.kind}-${item.id}`}>
|
||||
{/* Wie in der Historie: der Klick führt zum Vorgang — in die
|
||||
Akte, Reiter Historie; bei einer Wiedervorlage zu den
|
||||
Notizen, denn dort steht sie. Fachlich so vorgegeben. */}
|
||||
<Link
|
||||
href={`/employees/${item.employeeId}`}
|
||||
href={`/employees/${item.employeeId}?tab=${encodeURIComponent(item.kind === "note" ? "HR-Notizen" : "Historie")}`}
|
||||
className="-mx-2 flex items-center justify-between gap-2 rounded px-2 py-2.5 text-sm hover:bg-surface"
|
||||
>
|
||||
<span className="min-w-0">
|
||||
|
||||
@@ -16,6 +16,7 @@ import type { Database } from "@/lib/types";
|
||||
import { DatenAendernPanel } from "./panels/DatenAendernPanel";
|
||||
import { KarenzPanel } from "./panels/KarenzPanel";
|
||||
import type { GeplanterVorgang } from "@/lib/geplanter-vorgang";
|
||||
import type { Notfallkontakt } from "./NotfallkontaktModal";
|
||||
import { PromotePanel } from "./panels/PromotePanel";
|
||||
import { RehireWizard } from "../hire/RehireWizard";
|
||||
import { TerminatePanel } from "./panels/TerminatePanel";
|
||||
@@ -53,12 +54,15 @@ type EmployeeDetailProps = {
|
||||
directReports: MiniEmployee[];
|
||||
history: HistoryRow[];
|
||||
dependents: Dependent[];
|
||||
notfallkontakte: Notfallkontakt[];
|
||||
/** vonMir: von der angemeldeten Person verfasst — nur sie darf löschen. */
|
||||
notes: (NoteRow & { vonMir?: boolean })[];
|
||||
locations: Location[];
|
||||
openPositions: OpenPositionResolved[];
|
||||
/** Der Tag, zu dem die Akte gelesen wurde — derselbe wie in loadEmployeeDetail. */
|
||||
today: string;
|
||||
/** Reiter, mit dem die Akte öffnet (?tab= in der Adresse); sonst Stammdaten. */
|
||||
startTab?: string;
|
||||
};
|
||||
|
||||
type PanelType = "transfer" | "promote" | "karenz" | "daten" | "terminate" | "rehire" | null;
|
||||
@@ -67,7 +71,12 @@ type Tab = (typeof ALLE_TABS)[number];
|
||||
|
||||
export function EmployeeDetail(props: EmployeeDetailProps) {
|
||||
const { employee, placement, breadcrumb, kostenstelle, onboarding, offboarding, manager, formalManager, directReports, history, dependents, notes, locations, openPositions, today } = props;
|
||||
const [tab, setTab] = useState<Tab>("Stammdaten");
|
||||
// Wer aus „Anstehend" kommt, will den Vorgang sehen und nicht die
|
||||
// Stammdaten — die Übersicht verlinkt deshalb mit ?tab=. Unbekanntes führt
|
||||
// auf die Stammdaten.
|
||||
const [tab, setTab] = useState<Tab>(
|
||||
(ALLE_TABS as readonly string[]).includes(props.startTab ?? "") ? (props.startTab as Tab) : "Stammdaten"
|
||||
);
|
||||
const [panel, setPanel] = useState<PanelType>(null);
|
||||
const [geplant, setGeplant] = useState<GeplanterVorgang | null>(null);
|
||||
|
||||
@@ -201,8 +210,26 @@ export function EmployeeDetail(props: EmployeeDetailProps) {
|
||||
</div>
|
||||
|
||||
<div className="rounded border border-border bg-white p-6">
|
||||
{tab === "Stammdaten" && <StammdatenTab employee={employee} location={location} dependents={dependents} />}
|
||||
{tab === "Vertrag" && <VertragTab employee={employee} />}
|
||||
{tab === "Stammdaten" && (
|
||||
<StammdatenTab
|
||||
employee={employee}
|
||||
location={location}
|
||||
dependents={dependents}
|
||||
notfallkontakte={props.notfallkontakte}
|
||||
/>
|
||||
)}
|
||||
{tab === "Vertrag" && (
|
||||
<VertragTab
|
||||
employee={employee}
|
||||
uebernahmeAm={
|
||||
history
|
||||
.filter((h) => h.event_type === "Übernahme" && h.event_date <= today)
|
||||
.map((h) => h.event_date)
|
||||
.sort()
|
||||
.at(-1) ?? null
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{tab === "Organisation" && (
|
||||
<OrganisationTab
|
||||
employeeId={employee.id}
|
||||
@@ -291,6 +318,7 @@ export function EmployeeDetail(props: EmployeeDetailProps) {
|
||||
employee={employee}
|
||||
dependents={dependents}
|
||||
locationCountry={location?.country}
|
||||
notfallkontakte={props.notfallkontakte}
|
||||
planstelle={placement ? { positionNumber: placement.positionNumber, jobTitle: placement.jobTitle } : null}
|
||||
// Wie in eintritt_planstelle_berichtigen: berichtigt wird nur, solange
|
||||
// seit dem Eintritt keine Versetzung und keine Beförderung steht.
|
||||
|
||||
@@ -2,28 +2,25 @@
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { changeEmployeeData } from "@/actions/employees";
|
||||
import { addEmergencyContact, updateEmergencyContact } from "@/actions/employees";
|
||||
import { Button } from "@/components/ui/Button";
|
||||
import { VerhaeltnisField } from "@/components/employees/VerhaeltnisField";
|
||||
import { TextField } from "@/components/ui/Field";
|
||||
import { Modal } from "@/components/ui/Modal";
|
||||
import { useToast } from "@/components/ui/Toast";
|
||||
import { todayIso } from "@/lib/format";
|
||||
|
||||
// Der Notfallkontakt, ohne den Umweg über „Daten ändern".
|
||||
// Einen Notfallkontakt anlegen oder ändern — dasselbe Fenster für beides,
|
||||
// wie bei den Angehörigen.
|
||||
//
|
||||
// Geschrieben wird über dieselbe Funktion wie dort: change_employee_data mit
|
||||
// **nur** den drei Feldern im Abschnitt `person`. Das ist keine Abkürzung,
|
||||
// sondern die Bedingung dafür, dass der Eintrag in der Historie und im
|
||||
// Protokoll landet wie jede andere Stammdatenänderung. Die Datenbank fasst
|
||||
// ausschliesslich die Felder an, die im Aufruf stehen — sie prüft auf das
|
||||
// Vorhandensein des Schlüssels, nicht auf seinen Wert (Migration
|
||||
// 20260917120000). Adresse, E-Mail und der Rest bleiben deshalb unberührt.
|
||||
// Kein „Wirksam ab": ein Notfallkontakt gilt ab sofort. Bei einer Nummer, die
|
||||
// im Ernstfall gewählt wird, ist ein Datum in der Zukunft keine sinnvolle
|
||||
// Angabe, sondern eine Frage zu viel.
|
||||
|
||||
export type Notfallkontakt = {
|
||||
name: string | null;
|
||||
telefon: string | null;
|
||||
verhaeltnis: string | null;
|
||||
id: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
relation: string | null;
|
||||
};
|
||||
|
||||
export function NotfallkontaktModal({
|
||||
@@ -31,24 +28,20 @@ export function NotfallkontaktModal({
|
||||
onClose,
|
||||
employeeId,
|
||||
kontakt,
|
||||
effectiveDate,
|
||||
}: {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
employeeId: string;
|
||||
kontakt: Notfallkontakt;
|
||||
/** Aus „Daten ändern"; ohne Angabe gilt heute. */
|
||||
effectiveDate?: string;
|
||||
/** Der zu ändernde Kontakt; ohne ihn wird einer angelegt. */
|
||||
kontakt: Notfallkontakt | null;
|
||||
}) {
|
||||
const { showToast } = useToast();
|
||||
const router = useRouter();
|
||||
const [name, setName] = useState(kontakt.name ?? "");
|
||||
const [telefon, setTelefon] = useState(kontakt.telefon ?? "");
|
||||
const [verhaeltnis, setVerhaeltnis] = useState(kontakt.verhaeltnis ?? "");
|
||||
const [name, setName] = useState(kontakt?.name ?? "");
|
||||
const [telefon, setTelefon] = useState(kontakt?.phone ?? "");
|
||||
const [verhaeltnis, setVerhaeltnis] = useState(kontakt?.relation ?? "");
|
||||
const [pending, setPending] = useState(false);
|
||||
|
||||
const vorhanden = Boolean(kontakt.name);
|
||||
|
||||
async function handleSubmit() {
|
||||
// Name und Telefonnummer gehören zusammen: ein Name ohne Nummer hilft im
|
||||
// Ernstfall niemandem, eine Nummer ohne Namen sagt nicht, wen man dran
|
||||
@@ -58,20 +51,13 @@ export function NotfallkontaktModal({
|
||||
return;
|
||||
}
|
||||
setPending(true);
|
||||
const result = await changeEmployeeData({
|
||||
employee_id: employeeId,
|
||||
effective_date: effectiveDate || todayIso(),
|
||||
person: {
|
||||
emergency_contact_name: name.trim(),
|
||||
emergency_contact_phone: telefon.trim(),
|
||||
emergency_contact_relation: verhaeltnis.trim(),
|
||||
},
|
||||
contract: {},
|
||||
role: {},
|
||||
});
|
||||
const angaben = { name: name.trim(), phone: telefon.trim(), relation: verhaeltnis.trim() };
|
||||
const result = kontakt
|
||||
? await updateEmergencyContact({ ...angaben, id: kontakt.id, employee_id: employeeId })
|
||||
: await addEmergencyContact({ ...angaben, employee_id: employeeId });
|
||||
setPending(false);
|
||||
if (result.success) {
|
||||
showToast(vorhanden ? "Notfallkontakt geändert." : "Notfallkontakt hinterlegt.");
|
||||
showToast(kontakt ? "Notfallkontakt geändert." : "Notfallkontakt hinzugefügt.");
|
||||
router.refresh();
|
||||
onClose();
|
||||
} else {
|
||||
@@ -83,7 +69,7 @@ export function NotfallkontaktModal({
|
||||
<Modal
|
||||
open={open}
|
||||
onClose={onClose}
|
||||
title={vorhanden ? "Notfallkontakt ändern" : "Notfallkontakt hinterlegen"}
|
||||
title={kontakt ? "Notfallkontakt ändern" : "Notfallkontakt hinzufügen"}
|
||||
footer={
|
||||
<>
|
||||
<Button variant="ghost" onClick={onClose}>
|
||||
@@ -95,15 +81,11 @@ export function NotfallkontaktModal({
|
||||
</>
|
||||
}
|
||||
>
|
||||
{/* Kein „Wirksam ab", obwohl die Datenbankfunktion einen Stichtag
|
||||
kennt: ein Notfallkontakt gilt ab sofort. Bei einer Telefonnummer,
|
||||
die im Ernstfall gewählt wird, ist ein Datum in der Zukunft keine
|
||||
sinnvolle Angabe, sondern eine Frage zu viel. */}
|
||||
<div className="flex flex-col gap-4">
|
||||
<TextField label="Name" required value={name} onChange={setName} />
|
||||
<TextField label="Telefonnummer" required type="tel" value={telefon} onChange={setTelefon} />
|
||||
{/* Dasselbe Bauteil wie im Einstellungsassistenten: die Liste, und
|
||||
unter „Sonstige" ein Freifeld. */}
|
||||
{/* Dasselbe Bauteil wie im Einstellungsassistenten: die Liste der
|
||||
Angehörigen, und unter „Sonstige" ein Freifeld. */}
|
||||
<VerhaeltnisField value={verhaeltnis} onChange={setVerhaeltnis} />
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
@@ -3,57 +3,35 @@
|
||||
import { Pencil, Plus, Trash2 } from "lucide-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { changeEmployeeData } from "@/actions/employees";
|
||||
import { deleteEmergencyContact } from "@/actions/employees";
|
||||
import { Button } from "@/components/ui/Button";
|
||||
import { useToast } from "@/components/ui/Toast";
|
||||
import { todayIso } from "@/lib/format";
|
||||
import { anzeige } from "@/lib/anzeige";
|
||||
import { NotfallkontaktModal, type Notfallkontakt } from "./NotfallkontaktModal";
|
||||
|
||||
// Eigener Abschnitt statt einer Zelle im Raster, und unterhalb der
|
||||
// Angehörigen: beides sind Personen im Umfeld, und der Notfallkontakt ist die
|
||||
// Ausnahme davon — deshalb steht er zuletzt, nicht dazwischen. Im Ernstfall
|
||||
// greift jemand in Eile danach; dann muss die Nummer sofort zu finden sein
|
||||
// und wählbar.
|
||||
// Die Notfallkontakte einer Person — so viele, wie es braucht, angelegt und
|
||||
// geändert wie die Angehörigen darüber (fachlich so vorgegeben).
|
||||
//
|
||||
// Der Knopf steht hier, weil er bei den Angehörigen darüber auch steht. Ohne
|
||||
// ihn führte der einzige Weg über „Daten ändern" — ein Formular über alle
|
||||
// Stammdaten, um eine Telefonnummer einzutragen.
|
||||
// Eigener Abschnitt unterhalb der Angehörigen: im Ernstfall greift jemand in
|
||||
// Eile danach; dann muss die Nummer sofort zu finden sein und wählbar.
|
||||
|
||||
export function NotfallkontaktSection({
|
||||
employeeId,
|
||||
kontakt,
|
||||
effectiveDate,
|
||||
kontakte,
|
||||
}: {
|
||||
employeeId: string;
|
||||
kontakt: Notfallkontakt;
|
||||
/**
|
||||
* Nur, wenn der Abschnitt in „Daten ändern" steht: dann treibt dessen
|
||||
* „Wirksam ab" auch diesen Vorgang — wie bei den Angehörigen darüber.
|
||||
* Ohne Angabe gilt heute.
|
||||
*/
|
||||
effectiveDate?: string;
|
||||
kontakte: Notfallkontakt[];
|
||||
}) {
|
||||
const { showToast } = useToast();
|
||||
const router = useRouter();
|
||||
const [modalOpen, setModalOpen] = useState(false);
|
||||
const [entfernt, setEntfernt] = useState(false);
|
||||
const stichtag = effectiveDate || todayIso();
|
||||
const [bearbeitet, setBearbeitet] = useState<Notfallkontakt | null>(null);
|
||||
const [entferntId, setEntferntId] = useState<string | null>(null);
|
||||
|
||||
const vorhanden = Boolean(kontakt.name);
|
||||
|
||||
async function handleEntfernen() {
|
||||
setEntfernt(true);
|
||||
// Leere Zeichenketten, nicht ausgelassene Felder: die Datenbank macht
|
||||
// daraus null. Würden die Schlüssel fehlen, bliebe der Kontakt stehen.
|
||||
const result = await changeEmployeeData({
|
||||
employee_id: employeeId,
|
||||
effective_date: stichtag,
|
||||
person: { emergency_contact_name: "", emergency_contact_phone: "", emergency_contact_relation: "" },
|
||||
contract: {},
|
||||
role: {},
|
||||
});
|
||||
setEntfernt(false);
|
||||
async function handleEntfernen(k: Notfallkontakt) {
|
||||
setEntferntId(k.id);
|
||||
const result = await deleteEmergencyContact({ id: k.id, employee_id: employeeId });
|
||||
setEntferntId(null);
|
||||
if (result.success) {
|
||||
showToast("Notfallkontakt entfernt.");
|
||||
router.refresh();
|
||||
@@ -65,27 +43,23 @@ export function NotfallkontaktSection({
|
||||
return (
|
||||
<div className="border-t border-border pt-6">
|
||||
<div className="mb-3 flex items-center justify-between">
|
||||
<h3 className="text-xs font-bold uppercase tracking-wide text-brand-700">Notfallkontakt</h3>
|
||||
{/* Nur, solange keiner hinterlegt ist: es gibt genau einen. Ein
|
||||
zweites „Hinzufügen" daneben verspräche eine Liste, die es hier
|
||||
nicht gibt — geändert und entfernt wird in der Zeile selbst. */}
|
||||
{!vorhanden && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => setModalOpen(true)}
|
||||
className="!px-1 text-brand-700 hover:!bg-transparent hover:underline"
|
||||
>
|
||||
<Plus className="h-3.5 w-3.5" /> Hinzufügen
|
||||
</Button>
|
||||
)}
|
||||
<h3 className="text-xs font-bold uppercase tracking-wide text-brand-700">Notfallkontakte</h3>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
setBearbeitet(null);
|
||||
setModalOpen(true);
|
||||
}}
|
||||
className="!px-1 text-brand-700 hover:!bg-transparent hover:underline"
|
||||
>
|
||||
<Plus className="h-3.5 w-3.5" /> Hinzufügen
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* Dieselbe Tabelle wie bei den Angehörigen darüber, Zeile für Zeile
|
||||
derselbe Aufbau. Eine Beschreibungsliste wäre fachlich dasselbe,
|
||||
optisch aber ein zweiter Baustil im selben Reiter. Zwei Listen
|
||||
von Personen im Umfeld sollen gleich aussehen. */}
|
||||
{vorhanden ? (
|
||||
{/* Dieselbe Tabelle wie bei den Angehörigen darüber: zwei Listen von
|
||||
Personen im Umfeld sollen gleich aussehen. */}
|
||||
{kontakte.length > 0 ? (
|
||||
<div className="overflow-x-auto rounded border border-border">
|
||||
<table className="w-full min-w-[600px] text-sm">
|
||||
<thead>
|
||||
@@ -97,43 +71,44 @@ export function NotfallkontaktSection({
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr className="border-b border-border last:border-0">
|
||||
<td className="px-4 py-2.5 font-semibold text-ink">{kontakt.name}</td>
|
||||
<td className="px-4 py-2.5 text-ink-body">
|
||||
{kontakt.telefon ? (
|
||||
// Wählbar: im Ernstfall greift jemand in Eile danach.
|
||||
{kontakte.map((k) => (
|
||||
<tr key={k.id} className="border-b border-border last:border-0">
|
||||
<td className="px-4 py-2.5 font-semibold text-ink">{k.name}</td>
|
||||
<td className="px-4 py-2.5 text-ink-body">
|
||||
{/* Wählbar: im Ernstfall greift jemand in Eile danach. */}
|
||||
<a
|
||||
href={`tel:${kontakt.telefon.replace(/\s/g, "")}`}
|
||||
href={`tel:${k.phone.replace(/\s/g, "")}`}
|
||||
className="rounded font-semibold hover:text-brand-700 hover:underline
|
||||
focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-500"
|
||||
>
|
||||
{kontakt.telefon}
|
||||
{k.phone}
|
||||
</a>
|
||||
) : (
|
||||
"–"
|
||||
)}
|
||||
</td>
|
||||
<td className="px-4 py-2.5 text-ink-body">{anzeige(kontakt.verhaeltnis) || "–"}</td>
|
||||
<td className="px-4 py-2.5 text-right">
|
||||
<Button
|
||||
variant="icon"
|
||||
onClick={() => setModalOpen(true)}
|
||||
aria-label="Notfallkontakt ändern"
|
||||
className="hover:!text-brand-700"
|
||||
>
|
||||
<Pencil className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="icon"
|
||||
onClick={handleEntfernen}
|
||||
pending={entfernt}
|
||||
aria-label="Notfallkontakt entfernen"
|
||||
className="hover:!text-danger-solid"
|
||||
>
|
||||
<Trash2 className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
<td className="px-4 py-2.5 text-ink-body">{anzeige(k.relation) || "–"}</td>
|
||||
<td className="px-4 py-2.5 text-right">
|
||||
<Button
|
||||
variant="icon"
|
||||
onClick={() => {
|
||||
setBearbeitet(k);
|
||||
setModalOpen(true);
|
||||
}}
|
||||
aria-label={`Notfallkontakt ${k.name} ändern`}
|
||||
className="hover:!text-brand-700"
|
||||
>
|
||||
<Pencil className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="icon"
|
||||
onClick={() => handleEntfernen(k)}
|
||||
pending={entferntId === k.id}
|
||||
aria-label={`Notfallkontakt ${k.name} entfernen`}
|
||||
className="hover:!text-danger-solid"
|
||||
>
|
||||
<Trash2 className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -141,17 +116,17 @@ export function NotfallkontaktSection({
|
||||
<p className="text-sm text-ink-muted">Kein Notfallkontakt hinterlegt.</p>
|
||||
)}
|
||||
|
||||
{/* `key` setzt die Felder auf den gespeicherten Stand zurück, sobald
|
||||
sich der Kontakt geändert hat — das Fenster bleibt sonst montiert
|
||||
und zeigte beim zweiten Öffnen den alten Entwurf. */}
|
||||
<NotfallkontaktModal
|
||||
key={`${kontakt.name ?? ""}|${kontakt.telefon ?? ""}|${kontakt.verhaeltnis ?? ""}`}
|
||||
open={modalOpen}
|
||||
onClose={() => setModalOpen(false)}
|
||||
employeeId={employeeId}
|
||||
kontakt={kontakt}
|
||||
effectiveDate={stichtag}
|
||||
/>
|
||||
{/* `key` baut das Fenster je Kontakt neu auf — sonst zeigte es beim
|
||||
zweiten Öffnen die Felder des vorigen. */}
|
||||
{modalOpen && (
|
||||
<NotfallkontaktModal
|
||||
key={bearbeitet?.id ?? "neu"}
|
||||
open
|
||||
onClose={() => setModalOpen(false)}
|
||||
employeeId={employeeId}
|
||||
kontakt={bearbeitet}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import { NotfallkontaktSection } from "@/components/employees/NotfallkontaktSect
|
||||
import { AustrittZuruecknehmen } from "@/components/employees/AustrittZuruecknehmen";
|
||||
import { EintrittPlanstelleBerichtigen } from "@/components/employees/EintrittPlanstelleBerichtigen";
|
||||
import type { OpenPositionResolved } from "@/lib/positions";
|
||||
import type { Notfallkontakt } from "@/components/employees/NotfallkontaktModal";
|
||||
import type { ContractType, Database, EmploymentType, GenderType, PaygradeType } from "@/lib/types";
|
||||
|
||||
type EmployeeRow = Database["public"]["Tables"]["employees"]["Row"];
|
||||
@@ -49,6 +50,7 @@ export function DatenAendernPanel({
|
||||
planstelle = null,
|
||||
planstelleBerichtigbar = false,
|
||||
openPositions = [],
|
||||
notfallkontakte = [],
|
||||
}: {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
@@ -60,6 +62,7 @@ export function DatenAendernPanel({
|
||||
/** Kein Versetzung oder Beförderung seit dem Eintritt — dann lässt sie sich hier berichtigen. */
|
||||
planstelleBerichtigbar?: boolean;
|
||||
openPositions?: OpenPositionResolved[];
|
||||
notfallkontakte?: Notfallkontakt[];
|
||||
}) {
|
||||
const { showToast } = useToast();
|
||||
const router = useRouter();
|
||||
@@ -622,17 +625,10 @@ export function DatenAendernPanel({
|
||||
{/* Derselbe Abschnitt wie im Reiter „Stammdaten", unmittelbar unter den
|
||||
Angehörigen — beides Personen im Umfeld, beides dieselbe Tabelle
|
||||
mit denselben Knöpfen. Lose Eingabefelder wären fachlich dasselbe,
|
||||
aber eine zweite Bauform für denselben Zweck. Beide Abschnitte
|
||||
laufen über das „Wirksam ab" dieses Formulars. */}
|
||||
<NotfallkontaktSection
|
||||
employeeId={employee.id}
|
||||
effectiveDate={effectiveDate}
|
||||
kontakt={{
|
||||
name: employee.emergency_contact_name,
|
||||
telefon: employee.emergency_contact_phone,
|
||||
verhaeltnis: employee.emergency_contact_relation,
|
||||
}}
|
||||
/>
|
||||
aber eine zweite Bauform für denselben Zweck. Die Angehörigen
|
||||
laufen über das „Wirksam ab" dieses Formulars; ein Notfallkontakt
|
||||
gilt ab sofort. */}
|
||||
<NotfallkontaktSection employeeId={employee.id} kontakte={notfallkontakte} />
|
||||
</div>
|
||||
</SlideOver>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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";
|
||||
@@ -11,7 +12,17 @@ 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 }: { employee: EmployeeRow; location?: Location; dependents: Dependent[] }) {
|
||||
export function StammdatenTab({
|
||||
employee,
|
||||
location,
|
||||
dependents,
|
||||
notfallkontakte,
|
||||
}: {
|
||||
employee: EmployeeRow;
|
||||
location?: Location;
|
||||
dependents: Dependent[];
|
||||
notfallkontakte: Notfallkontakt[];
|
||||
}) {
|
||||
// Defensive against a DB that hasn't received the title_prefix/title_suffix
|
||||
// migration yet — select("*") simply omits unknown columns, so these can
|
||||
// be undefined rather than the empty array the column default implies.
|
||||
@@ -83,14 +94,7 @@ export function StammdatenTab({ employee, location, dependents }: { employee: Em
|
||||
|
||||
<AngehoerigeSection employeeId={employee.id} dependents={dependents} />
|
||||
|
||||
<NotfallkontaktSection
|
||||
employeeId={employee.id}
|
||||
kontakt={{
|
||||
name: employee.emergency_contact_name,
|
||||
telefon: employee.emergency_contact_phone,
|
||||
verhaeltnis: employee.emergency_contact_relation,
|
||||
}}
|
||||
/>
|
||||
<NotfallkontaktSection employeeId={employee.id} kontakte={notfallkontakte} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,14 @@ function behinderungText(e: EmployeeRow): string {
|
||||
return teile.length > 0 ? teile.join(" · ") : "Ja";
|
||||
}
|
||||
|
||||
export function VertragTab({ employee }: { employee: EmployeeRow }) {
|
||||
export function VertragTab({
|
||||
employee,
|
||||
uebernahmeAm = null,
|
||||
}: {
|
||||
employee: EmployeeRow;
|
||||
/** Datum der Übernahme von extern aus der Historie; null heisst keine. */
|
||||
uebernahmeAm?: string | null;
|
||||
}) {
|
||||
// Jedes Merkmal steht für sich, mit Ja oder Nein, wie jede andere Zeile auf
|
||||
// diesem Blatt auch. Eine Sammelzeile mit allem, was zutrifft, und einem
|
||||
// Gedankenstrich, wenn nichts zutrifft, liesse nicht ablesen, ob jemand
|
||||
@@ -64,6 +71,11 @@ export function VertragTab({ employee }: { employee: EmployeeRow }) {
|
||||
// Wie beim Dienstwagen: statt eines blossen „Ja" gleich die Regelung.
|
||||
["Bonusanspruch", bonusanspruchLabel(employee.has_bonusanspruch, employee.bonusanspruch_art)],
|
||||
["Beschäftigtengruppe", anzeige(employee.worker_type) ?? "–"],
|
||||
["Besetzungsart", employee.source],
|
||||
// Fachlich vorgegeben: ob die Person von extern übernommen wurde. Gelesen
|
||||
// aus dem Ereignis „Übernahme" in der Historie und nicht als eigene
|
||||
// Spalte geführt — so kann die Angabe dem Ereignis nicht widersprechen.
|
||||
["Übernahme", uebernahmeAm ? `Ja (am ${fmtDate(uebernahmeAm)})` : "Nein"],
|
||||
["Arbeitstage", employee.work_days?.join(", ") || "–"],
|
||||
// Beim Dienstwagen steht die Antriebsart statt eines blossen „Ja" — darum
|
||||
// geht es bei der Frage, weil E-Fahrzeuge getrennt zu führen sind.
|
||||
|
||||
@@ -29,6 +29,9 @@ export function NotesBell({ notes, kollegen }: { notes: OpenNote[]; kollegen: Ko
|
||||
|
||||
const sichtbarkeit = (k: Kollege) => eigen[k.id] ?? k.sichtbar;
|
||||
const dazugewaehlt = kollegen.filter((k) => sichtbarkeit(k)).length;
|
||||
const [nurMeine, setNurMeine] = useState(false);
|
||||
// Ohne hinzugewählte Kollegen sind ohnehin nur die eigenen da.
|
||||
const sichtbar = nurMeine && dazugewaehlt > 0 ? notes.filter((n) => n.vonMir) : notes;
|
||||
|
||||
async function schalte(k: Kollege) {
|
||||
const neu = !sichtbarkeit(k);
|
||||
@@ -85,9 +88,26 @@ export function NotesBell({ notes, kollegen }: { notes: OpenNote[]; kollegen: Ko
|
||||
{open && (
|
||||
<div className="absolute right-0 z-20 mt-2 max-h-[28rem] w-96 overflow-y-auto rounded border border-border bg-white shadow-[var(--shadow-card-hover)]">
|
||||
<div className="flex items-center justify-between gap-2 border-b border-border px-4 py-2.5">
|
||||
<span className="text-xs font-bold uppercase tracking-wide text-ink-muted">
|
||||
Meine Notizen ({notes.length})
|
||||
</span>
|
||||
{/* Sind Kollegen hinzugewählt, ist „Meine Notizen" ein Schalter:
|
||||
ein Klick zeigt nur die selbst angelegten, ein zweiter wieder
|
||||
alle. Fachlich so vorgegeben. Ohne Kollegen gibt es nichts
|
||||
umzuschalten — dann bleibt es eine Überschrift. */}
|
||||
{dazugewaehlt > 0 ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setNurMeine((v) => !v)}
|
||||
aria-pressed={nurMeine}
|
||||
className={`rounded px-1.5 py-0.5 text-xs font-bold uppercase tracking-wide hover:bg-surface focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-500 ${
|
||||
nurMeine ? "bg-accent-200 text-brand-700" : "text-ink-muted"
|
||||
}`}
|
||||
>
|
||||
Meine Notizen ({notes.filter((n) => n.vonMir).length})
|
||||
</button>
|
||||
) : (
|
||||
<span className="text-xs font-bold uppercase tracking-wide text-ink-muted">
|
||||
Meine Notizen ({notes.length})
|
||||
</span>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setZeigeEinstellung((v) => !v)}
|
||||
@@ -136,11 +156,11 @@ export function NotesBell({ notes, kollegen }: { notes: OpenNote[]; kollegen: Ko
|
||||
</div>
|
||||
)}
|
||||
|
||||
{notes.length === 0 ? (
|
||||
{sichtbar.length === 0 ? (
|
||||
<p className="px-4 py-6 text-center text-sm text-ink-muted">Keine offenen Notizen.</p>
|
||||
) : (
|
||||
<ul className="divide-y divide-border">
|
||||
{notes.map((n) => (
|
||||
{sichtbar.map((n) => (
|
||||
<li key={n.id} className="px-4 py-3">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className={`rounded-full px-2 py-0.5 text-xs font-semibold ${NOTE_CATEGORY_STYLES[n.category]}`}>{n.category}</span>
|
||||
|
||||
Reference in New Issue
Block a user