diff --git a/ApiCore-Frontend/src/app/(app)/bottling/[id]/page.tsx b/ApiCore-Frontend/src/app/(app)/bottling/[id]/page.tsx index a6bbf1c..db4866b 100644 --- a/ApiCore-Frontend/src/app/(app)/bottling/[id]/page.tsx +++ b/ApiCore-Frontend/src/app/(app)/bottling/[id]/page.tsx @@ -11,41 +11,36 @@ import { useAuth } from "@/lib/auth/auth-context"; import { BottlingEditDialog } from "./bottling-edit-dialog"; import { BottlingDeleteButton } from "./bottling-delete-button"; import { PrintLabelsCard } from "./print-labels-card"; +import { DetailHeader, DetailQueryFallback } from "@/components/detail-header"; + +const BACK = { backHref: "/bottling", backLabel: "Alle Abfüllungen" }; export default function BottlingBatchDetailPage() { const params = useParams<{ id: string }>(); const { hasPermission } = useAuth(); - const { data: bottlingBatch, isLoading, isError } = useQuery({ + const bottlingQuery = useQuery({ queryKey: ["bottling-batches", params.id], queryFn: () => fetchBottlingBatch(params.id), }); + const bottlingBatch = bottlingQuery.data; - if (isLoading) { - return

Lädt…

; - } - if (isError || !bottlingBatch) { - return ( -

- Abfüllung konnte nicht geladen werden. -

- ); + if (bottlingQuery.isLoading || bottlingQuery.isError || !bottlingBatch) { + return ; } return (
+
- -
- - - - Abfüllung {bottlingBatch.lotNumber} -
-
+ + Angaben +
{hasPermission("bottling:update") ? ( ) : null} diff --git a/ApiCore-Frontend/src/app/(app)/equipment/[id]/page.tsx b/ApiCore-Frontend/src/app/(app)/equipment/[id]/page.tsx index 8fec8bb..5582a81 100644 --- a/ApiCore-Frontend/src/app/(app)/equipment/[id]/page.tsx +++ b/ApiCore-Frontend/src/app/(app)/equipment/[id]/page.tsx @@ -8,8 +8,6 @@ import { fetchEquipment, updateEquipment } from "@/lib/equipment/api"; import { EquipmentEditDialog } from "./equipment-edit-dialog"; import { EquipmentCondition } from "@/lib/equipment/types"; import { EQUIPMENT_CONDITIONS, EQUIPMENT_CONDITION_LABELS } from "@/lib/equipment/labels"; -import { statusTone } from "@/lib/status-tone"; -import { Badge } from "@/components/ui/badge"; import { Select, SelectContent, @@ -18,55 +16,52 @@ import { SelectValue, } from "@/components/ui/select"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { DetailHeader, DetailQueryFallback, DetailStatus } from "@/components/detail-header"; +import { errorMessage } from "@/lib/forms/error-message"; + +const BACK = { backHref: "/equipment", backLabel: "Gesamte Ausrüstung" }; export default function EquipmentDetailPage() { const params = useParams<{ id: string }>(); const queryClient = useQueryClient(); - const { data: equipment, isLoading, isError } = useQuery({ + const equipmentQuery = useQuery({ queryKey: ["equipment", params.id], queryFn: () => fetchEquipment(params.id), }); + const equipment = equipmentQuery.data; const updateMutation = useMutation({ mutationFn: (condition: EquipmentCondition) => updateEquipment(params.id, { condition }), - onSuccess: () => { + onSuccess: (_, condition) => { void queryClient.invalidateQueries({ queryKey: ["equipment", params.id] }); void queryClient.invalidateQueries({ queryKey: ["equipment"] }); + toast.success(`Zustand: ${EQUIPMENT_CONDITION_LABELS[condition]}`); }, - onError: () => toast.error("Zustand konnte nicht gespeichert werden"), + onError: (error) => toast.error(errorMessage(error, "Zustand konnte nicht gespeichert werden")), }); - if (isLoading) { - return

Lädt…

; - } - if (isError || !equipment) { - return ( -

- Gegenstand konnte nicht geladen werden. -

- ); + if (equipmentQuery.isLoading || equipmentQuery.isError || !equipment) { + return ; } return (
+ + } + {...BACK} + /> -
- - - - {equipment.name} -
-
- - {EQUIPMENT_CONDITION_LABELS[equipment.condition]} - - -
+ Angaben +

@@ -91,7 +86,7 @@ export default function EquipmentDetailPage() { value ? updateMutation.mutate(value as EquipmentCondition) : undefined } > - + {EQUIPMENT_CONDITION_LABELS[equipment.condition]} diff --git a/ApiCore-Frontend/src/app/(app)/extractions/[id]/page.tsx b/ApiCore-Frontend/src/app/(app)/extractions/[id]/page.tsx index 64ce8eb..5e0cbf5 100644 --- a/ApiCore-Frontend/src/app/(app)/extractions/[id]/page.tsx +++ b/ApiCore-Frontend/src/app/(app)/extractions/[id]/page.tsx @@ -7,45 +7,40 @@ import { useQuery } from "@tanstack/react-query"; import { fetchExtraction } from "@/lib/extractions/api"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { DetailHeader, DetailQueryFallback } from "@/components/detail-header"; import { ExtractionEditDialog } from "./extraction-edit-dialog"; +const BACK = { backHref: "/extractions", backLabel: "Alle Schleuderungen" }; + export default function ExtractionDetailPage() { const params = useParams<{ id: string }>(); - const { - data: extraction, - isLoading, - isError, - } = useQuery({ + const extractionQuery = useQuery({ queryKey: ["extractions", params.id], queryFn: () => fetchExtraction(params.id), }); + const extraction = extractionQuery.data; - if (isLoading) { - return

Lädt…

; - } - if (isError || !extraction) { + if (extractionQuery.isLoading || extractionQuery.isError || !extraction) { return ( -

- Schleuderung konnte nicht geladen werden. -

+ ); } return (
+ }> + Zu den Honigchargen + + } + {...BACK} + /> -
- - - - - Schleuderung vom {new Date(extraction.date).toLocaleDateString("de-DE")} - -
+ Angaben
@@ -63,7 +58,10 @@ export default function ExtractionDetailPage() {
    {extraction.harvests.map((entry) => (
  • - + {new Date(entry.harvest.date).toLocaleDateString("de-DE")} ·{" "} {entry.harvest.colonies.map((c) => c.colony.code).join(", ")} @@ -71,14 +69,6 @@ export default function ExtractionDetailPage() { ))}
-
diff --git a/ApiCore-Frontend/src/app/(app)/harvests/[id]/page.tsx b/ApiCore-Frontend/src/app/(app)/harvests/[id]/page.tsx index a6e9582..1cbaff7 100644 --- a/ApiCore-Frontend/src/app/(app)/harvests/[id]/page.tsx +++ b/ApiCore-Frontend/src/app/(app)/harvests/[id]/page.tsx @@ -7,63 +7,82 @@ import { useQuery } from "@tanstack/react-query"; import { fetchHarvest } from "@/lib/harvests/api"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { DetailHeader, DetailQueryFallback } from "@/components/detail-header"; import { HarvestEditDialog } from "./harvest-edit-dialog"; +const BACK = { backHref: "/harvests", backLabel: "Alle Ernten" }; + export default function HarvestDetailPage() { const params = useParams<{ id: string }>(); - const { data: harvest, isLoading, isError } = useQuery({ + const harvestQuery = useQuery({ queryKey: ["harvests", params.id], queryFn: () => fetchHarvest(params.id), }); + const harvest = harvestQuery.data; - if (isLoading) { - return

Lädt…

; - } - if (isError || !harvest) { - return ( -

- Ernte konnte nicht geladen werden. -

- ); + if (harvestQuery.isLoading || harvestQuery.isError || !harvest) { + return ; } return (
- - -
- - - - Ernte vom {new Date(harvest.date).toLocaleDateString("de-DE")} -
- -
- - {harvest.honeyType ?

Honigsorte: {harvest.honeyType}

: null} - {harvest.netWeight !== null ?

Nettogewicht: {harvest.netWeight} kg

: null} - {harvest.honeySuperCount !== null ? ( -

Honigräume: {harvest.honeySuperCount}

- ) : null} - {harvest.notes ?

Notizen: {harvest.notes}

: null} -
-

Beteiligte Völker

-
    - {harvest.colonies.map((entry) => ( -
  • {entry.colony.code}
  • - ))} -
-
+ } > - Zur Schleuderung + Schleuderung erfassen + } + {...BACK} + /> + + + Angaben + + + +
+ {harvest.honeyType ? ( + <> +
Honigsorte
+
{harvest.honeyType}
+ + ) : null} + {harvest.netWeight !== null ? ( + <> +
Nettogewicht
+
{harvest.netWeight} kg
+ + ) : null} + {harvest.honeySuperCount !== null ? ( + <> +
Honigräume
+
{harvest.honeySuperCount}
+ + ) : null} +
+ {harvest.notes ?

Notizen: {harvest.notes}

: null} +
+

Beteiligte Völker

+
    + {harvest.colonies.map((entry) => ( +
  • + + {entry.colony.code} + +
  • + ))} +
+