feat(frontend): Suche und Filter (Modul 14)
/search-Seite über Bienenstände, Völker, Königinnen, Aufgaben und Honigchargen. Filterleisten (Status/Standort) in den Listen-Views für Bienenstände, Völker, Königinnen und Honigchargen.
This commit is contained in:
1 parent
146b56d683
commit
166979ff3c
21 files changed
+314
-28
No files matched your search
@@ -1,9 +1,18 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { fetchHoneyBatches } from "@/lib/honey-batches/api";
|
||||
import { HoneyBatchStatus } from "@/lib/honey-batches/types";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
@@ -14,10 +23,23 @@ import {
|
||||
} from "@/components/ui/table";
|
||||
import { CreateHoneyBatchDialog } from "./create-honey-batch-dialog";
|
||||
|
||||
const STATUS_OPTIONS: HoneyBatchStatus[] = [
|
||||
"RAW",
|
||||
"EXTRACTED",
|
||||
"CLARIFIED",
|
||||
"CREAMED",
|
||||
"STORED",
|
||||
"BOTTLED",
|
||||
"SOLD",
|
||||
"CONSUMED",
|
||||
];
|
||||
|
||||
export default function HoneyBatchesPage() {
|
||||
const [status, setStatus] = useState<HoneyBatchStatus | "">("");
|
||||
|
||||
const { data: honeyBatches, isLoading, isError } = useQuery({
|
||||
queryKey: ["honey-batches"],
|
||||
queryFn: fetchHoneyBatches,
|
||||
queryKey: ["honey-batches", status],
|
||||
queryFn: () => fetchHoneyBatches({ status: status || undefined }),
|
||||
});
|
||||
|
||||
return (
|
||||
@@ -27,6 +49,25 @@ export default function HoneyBatchesPage() {
|
||||
<CreateHoneyBatchDialog />
|
||||
</div>
|
||||
|
||||
<Select
|
||||
value={status || "ALL"}
|
||||
onValueChange={(value) =>
|
||||
setStatus(value === "ALL" ? "" : ((value ?? "") as HoneyBatchStatus))
|
||||
}
|
||||
>
|
||||
<SelectTrigger className="w-40">
|
||||
<SelectValue placeholder="Status" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="ALL">Alle Status</SelectItem>
|
||||
{STATUS_OPTIONS.map((option) => (
|
||||
<SelectItem key={option} value={option}>
|
||||
{option}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
{isLoading ? <p className="text-sm text-muted-foreground">Lädt…</p> : null}
|
||||
{isError ? (
|
||||
<p role="alert" className="text-sm text-red-600">
|
||||
|
||||
Reference in new issue
Block a user