feat(frontend): Export-Buttons fuer Voelker, Honigchargen (Modul 21)
CSV-Export in den Listen-Views (Voelker, Honigchargen) und PDF-Rueckverfolgbarkeitsbericht auf der Honigcharge-Detailseite. apiFetchBlob() im API-Client ergaenzt fuer authentifizierte Blob-Downloads (JWT im Authorization-Header statt Cookie).
This commit is contained in:
1 parent
c281d04b16
commit
ed108045af
6 files changed
+114
-9
No files matched your search
@@ -2,9 +2,10 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { fetchColonies } from "@/lib/colonies/api";
|
||||
import { ColonyStatus } from "@/lib/colonies/types";
|
||||
import { exportColoniesCsv } from "@/lib/export/api";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import {
|
||||
@@ -42,13 +43,24 @@ export default function ColoniesPage() {
|
||||
queryFn: () => fetchColonies({ status: status || undefined }),
|
||||
});
|
||||
|
||||
const exportMutation = useMutation({ mutationFn: exportColoniesCsv });
|
||||
|
||||
return (
|
||||
<main className="flex flex-col gap-4 p-4 sm:p-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold">Völker</h1>
|
||||
<Button nativeButton={false} render={<Link href="/colonies/new" />}>
|
||||
+ Neues Volk
|
||||
</Button>
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
disabled={exportMutation.isPending}
|
||||
onClick={() => exportMutation.mutate()}
|
||||
>
|
||||
CSV exportieren
|
||||
</Button>
|
||||
<Button nativeButton={false} render={<Link href="/colonies/new" />}>
|
||||
+ Neues Volk
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Select
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
"use client";
|
||||
|
||||
import { useParams } from "next/navigation";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { fetchHoneyBatch, fetchHoneyBatchTraceability } from "@/lib/honey-batches/api";
|
||||
import { exportHoneyBatchTraceabilityPdf } from "@/lib/export/api";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { AddMeasurementDialog } from "./add-measurement-dialog";
|
||||
|
||||
@@ -18,6 +20,10 @@ export default function HoneyBatchDetailPage() {
|
||||
queryFn: () => fetchHoneyBatchTraceability(params.id),
|
||||
});
|
||||
|
||||
const exportPdfMutation = useMutation({
|
||||
mutationFn: () => exportHoneyBatchTraceabilityPdf(params.id),
|
||||
});
|
||||
|
||||
if (isLoading) {
|
||||
return <p className="p-4 text-sm text-muted-foreground sm:p-6">Lädt…</p>;
|
||||
}
|
||||
@@ -64,8 +70,16 @@ export default function HoneyBatchDetailPage() {
|
||||
</Card>
|
||||
|
||||
<Card className="max-w-lg">
|
||||
<CardHeader>
|
||||
<CardHeader className="flex flex-row items-center justify-between">
|
||||
<CardTitle>Rückverfolgbarkeit</CardTitle>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
disabled={exportPdfMutation.isPending}
|
||||
onClick={() => exportPdfMutation.mutate()}
|
||||
>
|
||||
PDF-Bericht
|
||||
</Button>
|
||||
</CardHeader>
|
||||
<CardContent className="flex flex-col gap-3 text-sm">
|
||||
{!traceability ? <p className="text-muted-foreground">Lädt…</p> : null}
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { fetchHoneyBatches } from "@/lib/honey-batches/api";
|
||||
import { HoneyBatchStatus } from "@/lib/honey-batches/types";
|
||||
import { exportHoneyBatchesCsv } from "@/lib/export/api";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
@@ -42,11 +44,22 @@ export default function HoneyBatchesPage() {
|
||||
queryFn: () => fetchHoneyBatches({ status: status || undefined }),
|
||||
});
|
||||
|
||||
const exportMutation = useMutation({ mutationFn: exportHoneyBatchesCsv });
|
||||
|
||||
return (
|
||||
<main className="flex flex-col gap-4 p-4 sm:p-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold">Honigchargen</h1>
|
||||
<CreateHoneyBatchDialog />
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
disabled={exportMutation.isPending}
|
||||
onClick={() => exportMutation.mutate()}
|
||||
>
|
||||
CSV exportieren
|
||||
</Button>
|
||||
<CreateHoneyBatchDialog />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Select
|
||||
|
||||
Reference in new issue
Block a user