diff --git a/components/employees/panels/TerminatePanel.tsx b/components/employees/panels/TerminatePanel.tsx index 933779c..ea3cc72 100644 --- a/components/employees/panels/TerminatePanel.tsx +++ b/components/employees/panels/TerminatePanel.tsx @@ -12,7 +12,18 @@ import { fmtName } from "@/lib/format"; type EmployeeRow = Database["public"]["Tables"]["employees"]["Row"]; -const EXIT_REASONS = ["Einvernehmliche Auflösung", "Kündigung AN", "Kündigung AG", "Befristungsablauf", "Pensionierung", "Entlassung"]; +// „No Show" steht am Ende und getrennt: es ist kein Austritt im gewohnten +// Sinn, sondern der Fall, dass jemand nie angetreten ist. +const NO_SHOW = "No Show"; +const EXIT_REASONS = [ + "Einvernehmliche Auflösung", + "Kündigung AN", + "Kündigung AG", + "Befristungsablauf", + "Pensionierung", + "Entlassung", + NO_SHOW, +]; const CHECKLIST_ITEMS = ["IT-Zugänge deaktivieren", "Hardware retournieren", "ÖGK-Abmeldung", "Endabrechnung & Dienstzeugnis"]; type TerminatePanelProps = { @@ -31,16 +42,32 @@ export function TerminatePanel({ open, onClose, employee, directReportCount }: T const [checked, setChecked] = useState(CHECKLIST_ITEMS.map(() => false)); const [pending, setPending] = useState(false); + // Bei einem Nichtantritt ist das Datum nicht frei wählbar: es ist der Tag, + // an dem die Person hätte anfangen sollen. Die Datenbank setzt es ohnehin + // so; hier steht es sichtbar, damit niemand ein Datum eintippt, das dann + // stillschweigend übergangen wird. + const istNoShow = reason === NO_SHOW; + const wirksamesDatum = istNoShow ? employee.entry_date : exitDate; + async function handleSubmit() { - if (!exitDate) { + if (!wirksamesDatum) { showToast("Bitte ein Austrittsdatum angeben.", "error"); return; } setPending(true); - const result = await terminateEmployee({ employee_id: employee.id, exit_date: exitDate, exit_reason: reason, note }); + const result = await terminateEmployee({ + employee_id: employee.id, + exit_date: wirksamesDatum, + exit_reason: reason, + note, + }); setPending(false); if (result.success) { - showToast(`Austritt für ${employee.first_name} ${employee.last_name} erfasst.`); + showToast( + istNoShow + ? `${employee.first_name} ${employee.last_name} ist nicht angetreten.` + : `Austritt für ${employee.first_name} ${employee.last_name} erfasst.` + ); router.refresh(); onClose(); } else { @@ -71,15 +98,34 @@ export function TerminatePanel({ open, onClose, employee, directReportCount }: T {directReportCount} direkte Berichte werden automatisch der nächsthöheren Führungskraft zugeordnet. )} - ({ value: r, label: r }))} + options={EXIT_REASONS.map((r) => ({ value: r, label: r === NO_SHOW ? "No Show (nicht angetreten)" : r }))} + /> + -
+ {istNoShow && ( +

+ Die Planstelle wird wieder frei und gilt als nie besetzt. In allen Auswertungen zählt die Person an keinem + Stichtag als beschäftigt. +

+ )} + {/* Bei einem Nichtantritt wurde nichts ausgegeben, was zurückkäme. */} +