"use client"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { rehireEmployee } from "@/actions/employees"; import { SlideOver } from "@/components/ui/SlideOver"; import { useToast } from "@/components/ui/Toast"; import { fmtDate } from "@/lib/format"; import type { Database } from "@/lib/supabase/types"; type EmployeeRow = Database["public"]["Tables"]["employees"]["Row"]; export function RehirePanel({ open, onClose, employee }: { open: boolean; onClose: () => void; employee: EmployeeRow }) { const { showToast } = useToast(); const router = useRouter(); const [rehireDate, setRehireDate] = useState(""); const [pending, setPending] = useState(false); async function handleSubmit() { if (!rehireDate) { showToast("Bitte ein Wiedereintrittsdatum angeben.", "error"); return; } setPending(true); const result = await rehireEmployee({ employee_id: employee.id, rehire_date: rehireDate }); setPending(false); if (result.success) { showToast(`${employee.first_name} ${employee.last_name} wurde wiedereingestellt.`); router.refresh(); onClose(); } else { showToast(result.error ?? "Fehler beim Speichern.", "error"); } } return ( } >

Letzte Position

{employee.job_title}

Ausgetreten am {fmtDate(employee.exit_date)}

setRehireDate(e.target.value)} className="w-full rounded border border-border px-3 py-2 text-sm" />
); }