From c91dc9ebf1631ed6162edcfca9643da762632553 Mon Sep 17 00:00:00 2001 From: Nick Szaunig Date: Fri, 4 Sep 2026 19:44:19 +0200 Subject: [PATCH] fix: add missing Ernten/Schleuderungen list and detail views The sidebar nav sent both entries straight to their "new" creation form, with no list page to ever browse what had been created - Schleuderung creation didn't even redirect to a detail page, just to /colonies, so a saved extraction left no trace anywhere in the UI. - New /harvests and /extractions list pages (mirrors the existing products/apiaries list pattern). - New /extractions/[id] detail page + edit dialog, matching the harvests one that already existed but had nothing linking to it. - Sidebar "Ernten"/"Schleuderungen" now point at the list pages instead of the creation forms. - Extraction creation now redirects to its detail page instead of /colonies. Co-Authored-By: Claude Sonnet 5 --- .../[id]/extraction-edit-dialog.tsx | 129 ++++++++++++++++++ .../src/app/(app)/extractions/[id]/page.tsx | 86 ++++++++++++ .../src/app/(app)/extractions/new/page.tsx | 6 +- .../src/app/(app)/extractions/page.tsx | 77 +++++++++++ .../src/app/(app)/harvests/page.tsx | 77 +++++++++++ ApiCore-Frontend/src/app/(app)/sidebar.tsx | 4 +- 6 files changed, 375 insertions(+), 4 deletions(-) create mode 100644 ApiCore-Frontend/src/app/(app)/extractions/[id]/extraction-edit-dialog.tsx create mode 100644 ApiCore-Frontend/src/app/(app)/extractions/[id]/page.tsx create mode 100644 ApiCore-Frontend/src/app/(app)/extractions/page.tsx create mode 100644 ApiCore-Frontend/src/app/(app)/harvests/page.tsx diff --git a/ApiCore-Frontend/src/app/(app)/extractions/[id]/extraction-edit-dialog.tsx b/ApiCore-Frontend/src/app/(app)/extractions/[id]/extraction-edit-dialog.tsx new file mode 100644 index 0000000..b449004 --- /dev/null +++ b/ApiCore-Frontend/src/app/(app)/extractions/[id]/extraction-edit-dialog.tsx @@ -0,0 +1,129 @@ +"use client"; + +import { FormEvent, useState } from "react"; +import { Pencil } from "lucide-react"; +import { useMutation, useQueryClient } from "@tanstack/react-query"; +import { updateExtraction } from "@/lib/extractions/api"; +import { Extraction } from "@/lib/extractions/types"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { Textarea } from "@/components/ui/textarea"; +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog"; + +export function ExtractionEditDialog({ extraction }: { extraction: Extraction }) { + const queryClient = useQueryClient(); + const [open, setOpen] = useState(false); + const [date, setDate] = useState(extraction.date.slice(0, 10)); + const [amount, setAmount] = useState(extraction.amount?.toString() ?? ""); + const [room, setRoom] = useState(extraction.room ?? ""); + const [waterContent, setWaterContent] = useState(extraction.waterContent?.toString() ?? ""); + const [temperature, setTemperature] = useState(extraction.temperature?.toString() ?? ""); + const [notes, setNotes] = useState(extraction.notes ?? ""); + + const mutation = useMutation({ + mutationFn: () => + updateExtraction(extraction.id, { + date: new Date(date).toISOString(), + amount: amount ? Number(amount) : undefined, + room: room || undefined, + waterContent: waterContent ? Number(waterContent) : undefined, + temperature: temperature ? Number(temperature) : undefined, + notes: notes || undefined, + }), + onSuccess: () => { + void queryClient.invalidateQueries({ queryKey: ["extractions", extraction.id] }); + setOpen(false); + }, + }); + + function handleSubmit(event: FormEvent) { + event.preventDefault(); + mutation.mutate(); + } + + return ( + + + + Bearbeiten + + } + /> + + + Schleuderung bearbeiten + +
+
+ + setDate(event.target.value)} + /> +
+
+
+ + setAmount(event.target.value)} + /> +
+
+ + setRoom(event.target.value)} + /> +
+
+
+
+ + setWaterContent(event.target.value)} + /> +
+
+ + setTemperature(event.target.value)} + /> +
+
+
+ +