"use client"; import { useState } from "react"; import { Check, X, Palmtree, House, Receipt, Clock, RotateCcw, Inbox } from "lucide-react"; import CanvasHint, { useCanvasHint } from "@/components/ui/CanvasHint"; /* ────────────────────────────────────────────────────────────────────────── * ApprovalInbox — interactive centrepiece for the mitarbeitermanagement page. * The team's open requests (Urlaub, Homeoffice, Spesen …); approve or reject * each one — the card gets a status stamp and slides out, the counter ticks * down, and an empty state lets you replay. Brand-styled. * ────────────────────────────────────────────────────────────────────────── */ type Status = "pending" | "approved" | "rejected"; type Request = { id: string; name: string; initials: string; color: string; typeLabel: string; detail: string; Icon: typeof Palmtree; }; const INITIAL: Request[] = [ { id: "r1", name: "Lena Krause", initials: "LK", color: "#0D6E6E", typeLabel: "Urlaubsantrag", detail: "12.–19. Juli · 6 Tage", Icon: Palmtree }, { id: "r2", name: "Tom Berger", initials: "TB", color: "#3B82F6", typeLabel: "Homeoffice", detail: "Freitag, 11. Juli", Icon: House }, { id: "r3", name: "Sara Möller", initials: "SM", color: "#F97316", typeLabel: "Spesenabrechnung", detail: "€ 84,50 · Tankbeleg", Icon: Receipt }, { id: "r4", name: "Jonas Weiß", initials: "JW", color: "#8B5CF6", typeLabel: "Überstundenabbau", detail: "3 Std. · Mittwoch", Icon: Clock }, ]; type Item = Request & { status: Status }; export default function ApprovalInbox({ hideHeader = false }: { hideHeader?: boolean }) { const [items, setItems] = useState(() => INITIAL.map((r) => ({ ...r, status: "pending" as Status }))); const hint = useCanvasHint(); const decide = (id: string, status: Status) => { hint.dismiss(); setItems((its) => its.map((it) => (it.id === id ? { ...it, status } : it))); // Let the stamp + slide animation play, then drop the row. window.setTimeout(() => setItems((its) => its.filter((it) => it.id !== id)), 520); }; const reset = () => setItems(INITIAL.map((r) => ({ ...r, status: "pending" as Status }))); const openCount = items.filter((it) => it.status === "pending").length; const allDone = items.length === 0; return (
{!hideHeader && (
ANTRÄGE

Anträge im Griff.

)} {/* Inbox on a dotted "canvas" — same treatment as the workflow editor & kanban board. The onboarding popup replaces the old caption. */}
{/* Inbox header */}
Offene Anträge {openCount > 0 ? `${openCount} zu bearbeiten` : "alles erledigt"}
{items.length < INITIAL.length && ( )}
{/* Requests */}
{allDone ? (
Alle Anträge bearbeitet
) : ( items.map((it) => { const decided = it.status !== "pending"; const approved = it.status === "approved"; return (
{/* left accent bar — the request's colour (matches the workflow nodes / kanban language) */} {/* Avatar + text — kept together; on mobile they sit above the actions */}
{it.initials}
{it.name} {it.typeLabel}
{it.detail}
{/* Actions / status — right on desktop, full row below on mobile */}
{decided ? ( {approved ? : } {approved ? "Genehmigt" : "Abgelehnt"} ) : (
)}
); }) )}
{/* Centered onboarding hint (dismisses on first decision or via X) */}
); }