From 29f6c4dec5e585c1ab533e81d0dae2d4b5a853d6 Mon Sep 17 00:00:00 2001 From: Jonny Date: Wed, 14 Oct 2026 10:49:52 +0200 Subject: [PATCH] feat: Suche und Schnellfilter ueber dem Kanban-Board Co-Authored-By: Claude Opus 5.5 --- web/app/dashboard/page.tsx | 18 ++- web/components/dashboard/KanbanBoard.tsx | 45 ++++++- .../dashboard/KanbanFilterleiste.tsx | 117 ++++++++++++++++++ 3 files changed, 176 insertions(+), 4 deletions(-) create mode 100644 web/components/dashboard/KanbanFilterleiste.tsx diff --git a/web/app/dashboard/page.tsx b/web/app/dashboard/page.tsx index 1c8805a..1777773 100644 --- a/web/app/dashboard/page.tsx +++ b/web/app/dashboard/page.tsx @@ -1,23 +1,35 @@ import { loadProfile } from "@/lib/auth/profile"; import { listAuftraegeFuerKanban, listFahrerNutzer } from "@/lib/dashboard/queries"; +import { parseKanbanFilter } from "@/lib/dashboard/kanban-filter"; import { KanbanBoard } from "@/components/dashboard/KanbanBoard"; -export default async function DashboardPage() { +export default async function DashboardPage({ + searchParams, +}: { + searchParams: Promise>; +}) { const profileResult = await loadProfile(); if (profileResult.status !== "ok") { return null; } const kannZuweisen = profileResult.profile.role === "admin" || profileResult.profile.role === "disponent"; - const [spalten, fahrerListe] = await Promise.all([ + const [spalten, fahrerListe, filter] = await Promise.all([ listAuftraegeFuerKanban(), kannZuweisen ? listFahrerNutzer() : Promise.resolve([]), + searchParams.then(parseKanbanFilter), ]); return (

Dashboard

- +
); } diff --git a/web/components/dashboard/KanbanBoard.tsx b/web/components/dashboard/KanbanBoard.tsx index eeab190..c29d408 100644 --- a/web/components/dashboard/KanbanBoard.tsx +++ b/web/components/dashboard/KanbanBoard.tsx @@ -22,7 +22,16 @@ import { uebernehmenVomBoard, stornierenVomBoard, zuweisenAnFahrer } from "@/app import { Card } from "@/components/ui/Card"; import { StatusBadge } from "@/components/ui/StatusBadge"; import { Alert } from "@/components/ui/Alert"; +import { + fahrerOptionen, + filterAlsSuchparameter, + filtereSpalten, + istFilterAktiv, + zaehle, + type KanbanFilter, +} from "@/lib/dashboard/kanban-filter"; import { FahrerAuswaehler } from "./FahrerAuswaehler"; +import { KanbanFilterleiste } from "./KanbanFilterleiste"; const SPALTEN_REIHENFOLGE: AuftragStatus[] = ["offen", "zugewiesen", "unterwegs", "abgeschlossen", "storniert"]; @@ -78,10 +87,12 @@ function KanbanSpalte({ status, auftraege, rolle, + filterAktiv, }: { status: AuftragStatus; auftraege: KanbanAuftrag[]; rolle: Role; + filterAktiv: boolean; }) { const { setNodeRef, isOver } = useDroppable({ id: status }); @@ -99,6 +110,9 @@ function KanbanSpalte({ {auftraege.map((auftrag) => ( ))} + {filterAktiv && auftraege.length === 0 && ( +

Keine Treffer

+ )} ); } @@ -109,19 +123,33 @@ export function KanbanBoard({ initialSpalten, fahrerListe, rolle, + initialFilter, + eigeneId, }: { initialSpalten: KanbanSpalten; fahrerListe: { id: string; name: string }[]; rolle: Role; + initialFilter: KanbanFilter; + eigeneId: string; }) { const [spalten, setSpalten] = useState(initialSpalten); const [fehler, setFehler] = useState(null); const [zuweisenDialog, setZuweisenDialog] = useState(null); + const [filter, setFilter] = useState(initialFilter); const sensors = useSensors( useSensor(PointerSensor, { activationConstraint: { distance: 8 } }), useSensor(KeyboardSensor), ); + function aendereFilter(neu: KanbanFilter) { + setFilter(neu); + const query = filterAlsSuchparameter(neu); + window.history.replaceState(null, "", query ? `?${query}` : window.location.pathname); + } + + const filterAktiv = istFilterAktiv(filter, rolle); + const sichtbar = filterAktiv ? filtereSpalten(spalten, filter, { rolle, eigeneId, jetzt: new Date() }) : spalten; + function verschiebeKarteLokal(auftragId: string, quelle: AuftragStatus, ziel: AuftragStatus) { setSpalten((bisher) => { const karte = bisher[quelle].find((a) => a.id === auftragId); @@ -178,6 +206,15 @@ export function KanbanBoard({ return (
+ {fehler && (
{fehler} @@ -186,7 +223,13 @@ export function KanbanBoard({
{SPALTEN_REIHENFOLGE.map((status) => ( - + ))}
diff --git a/web/components/dashboard/KanbanFilterleiste.tsx b/web/components/dashboard/KanbanFilterleiste.tsx new file mode 100644 index 0000000..40ac550 --- /dev/null +++ b/web/components/dashboard/KanbanFilterleiste.tsx @@ -0,0 +1,117 @@ +"use client"; + +import type { ReactNode } from "react"; +import type { Role } from "@/lib/auth/roles"; +import { FIELD_CLASSES } from "@/components/ui/FormField"; +import { LEERER_FILTER, type KanbanFilter, type TerminFilter } from "@/lib/dashboard/kanban-filter"; + +const TERMIN_OPTIONEN: { wert: TerminFilter; label: string }[] = [ + { wert: "alle", label: "Alle" }, + { wert: "heute", label: "Heute" }, + { wert: "morgen", label: "Morgen" }, +]; + +function Chip({ aktiv, onClick, children }: { aktiv: boolean; onClick: () => void; children: ReactNode }) { + return ( + + ); +} + +export function KanbanFilterleiste({ + filter, + onChange, + rolle, + fahrerOptionen, + gefiltert, + gesamt, + aktiv, +}: { + filter: KanbanFilter; + onChange: (filter: KanbanFilter) => void; + rolle: Role; + fahrerOptionen: { id: string; name: string }[]; + gefiltert: number; + gesamt: number; + aktiv: boolean; +}) { + const setze = (teil: Partial) => onChange({ ...filter, ...teil }); + + return ( +
+
+ setze({ q: e.target.value })} + placeholder="Suchen: Nr., Kennzeichen, Ort, Fahrer …" + aria-label="Aufträge durchsuchen" + maxLength={200} + enterKeyHint="search" + className={`${FIELD_CLASSES} pr-12 [&::-webkit-search-cancel-button]:appearance-none`} + /> + {filter.q && ( + + )} +
+
+
+ {TERMIN_OPTIONEN.map((option) => ( + setze({ termin: option.wert })}> + {option.label} + + ))} +
+ {rolle === "fahrer" ? ( + setze({ meine: !filter.meine })}> + Nur meine + + ) : ( + + )} +
+ {aktiv && ( +
+ + {gefiltert} von {gesamt} Aufträgen + + +
+ )} +
+ ); +}