fix: add error feedback to PDF/CSV export mutations
Export mutations (annual report PDFs, colony/honey-batch CSV exports) had no onError handler, so a failed download (network error, expired session) silently did nothing with zero user feedback. Same silent- failure class as the earlier onError sweep on entity-save mutations, here applied to the 5 remaining export/download call sites. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
1 parent
b4caa2ad5a
commit
4ec1468eb4
5 files changed
+16
-2
No files matched your search
@@ -3,6 +3,7 @@
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useParams } from "next/navigation";
|
import { useParams } from "next/navigation";
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
|
import { toast } from "sonner";
|
||||||
import { fetchApiary } from "@/lib/apiaries/api";
|
import { fetchApiary } from "@/lib/apiaries/api";
|
||||||
import { exportApiaryAnnualReportPdf } from "@/lib/export/api";
|
import { exportApiaryAnnualReportPdf } from "@/lib/export/api";
|
||||||
import { QrCodeDialog } from "@/components/qr-code-dialog";
|
import { QrCodeDialog } from "@/components/qr-code-dialog";
|
||||||
@@ -22,6 +23,7 @@ export default function ApiaryDetailPage() {
|
|||||||
|
|
||||||
const exportReportMutation = useMutation({
|
const exportReportMutation = useMutation({
|
||||||
mutationFn: () => exportApiaryAnnualReportPdf(params.id, CURRENT_YEAR),
|
mutationFn: () => exportApiaryAnnualReportPdf(params.id, CURRENT_YEAR),
|
||||||
|
onError: () => toast.error("Jahresbericht konnte nicht exportiert werden"),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { useParams } from "next/navigation";
|
import { useParams } from "next/navigation";
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
|
import { toast } from "sonner";
|
||||||
import { fetchColony } from "@/lib/colonies/api";
|
import { fetchColony } from "@/lib/colonies/api";
|
||||||
import { exportColonyAnnualReportPdf } from "@/lib/export/api";
|
import { exportColonyAnnualReportPdf } from "@/lib/export/api";
|
||||||
import { QrCodeDialog } from "@/components/qr-code-dialog";
|
import { QrCodeDialog } from "@/components/qr-code-dialog";
|
||||||
@@ -27,6 +28,7 @@ export default function ColonyDetailPage() {
|
|||||||
|
|
||||||
const exportReportMutation = useMutation({
|
const exportReportMutation = useMutation({
|
||||||
mutationFn: () => exportColonyAnnualReportPdf(params.id, CURRENT_YEAR),
|
mutationFn: () => exportColonyAnnualReportPdf(params.id, CURRENT_YEAR),
|
||||||
|
onError: () => toast.error("Jahresbericht konnte nicht exportiert werden"),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useState } from "react";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { Layers } from "lucide-react";
|
import { Layers } from "lucide-react";
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
|
import { toast } from "sonner";
|
||||||
import { fetchColonies } from "@/lib/colonies/api";
|
import { fetchColonies } from "@/lib/colonies/api";
|
||||||
import { ColonyStatus } from "@/lib/colonies/types";
|
import { ColonyStatus } from "@/lib/colonies/types";
|
||||||
import { COLONY_CONDITION_LABELS, COLONY_STATUS_LABELS, COLONY_TYPE_LABELS } from "@/lib/colonies/labels";
|
import { COLONY_CONDITION_LABELS, COLONY_STATUS_LABELS, COLONY_TYPE_LABELS } from "@/lib/colonies/labels";
|
||||||
@@ -35,7 +36,10 @@ export default function ColoniesPage() {
|
|||||||
queryFn: () => fetchColonies({}),
|
queryFn: () => fetchColonies({}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const exportMutation = useMutation({ mutationFn: exportColoniesCsv });
|
const exportMutation = useMutation({
|
||||||
|
mutationFn: exportColoniesCsv,
|
||||||
|
onError: () => toast.error("CSV-Export konnte nicht heruntergeladen werden"),
|
||||||
|
});
|
||||||
|
|
||||||
const activeColonies = (colonies ?? []).filter((colony) => colony.deactivatedAt === null);
|
const activeColonies = (colonies ?? []).filter((colony) => colony.deactivatedAt === null);
|
||||||
const historyColonies = (colonies ?? []).filter((colony) => colony.deactivatedAt !== null);
|
const historyColonies = (colonies ?? []).filter((colony) => colony.deactivatedAt !== null);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import Link from "next/link";
|
|||||||
import { useParams } from "next/navigation";
|
import { useParams } from "next/navigation";
|
||||||
import { Droplet, FlaskConical } from "lucide-react";
|
import { Droplet, FlaskConical } from "lucide-react";
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
|
import { toast } from "sonner";
|
||||||
import { fetchHoneyBatch, fetchHoneyBatchTraceability } from "@/lib/honey-batches/api";
|
import { fetchHoneyBatch, fetchHoneyBatchTraceability } from "@/lib/honey-batches/api";
|
||||||
import { HONEY_BATCH_STATUS_LABELS } from "@/lib/honey-batches/labels";
|
import { HONEY_BATCH_STATUS_LABELS } from "@/lib/honey-batches/labels";
|
||||||
import { exportHoneyBatchTraceabilityPdf } from "@/lib/export/api";
|
import { exportHoneyBatchTraceabilityPdf } from "@/lib/export/api";
|
||||||
@@ -32,6 +33,7 @@ export default function HoneyBatchDetailPage() {
|
|||||||
|
|
||||||
const exportPdfMutation = useMutation({
|
const exportPdfMutation = useMutation({
|
||||||
mutationFn: () => exportHoneyBatchTraceabilityPdf(params.id),
|
mutationFn: () => exportHoneyBatchTraceabilityPdf(params.id),
|
||||||
|
onError: () => toast.error("PDF-Bericht konnte nicht exportiert werden"),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Droplet } from "lucide-react";
|
import { Droplet } from "lucide-react";
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
|
import { toast } from "sonner";
|
||||||
import { fetchHoneyBatches } from "@/lib/honey-batches/api";
|
import { fetchHoneyBatches } from "@/lib/honey-batches/api";
|
||||||
import { HoneyBatchStatus } from "@/lib/honey-batches/types";
|
import { HoneyBatchStatus } from "@/lib/honey-batches/types";
|
||||||
import { HONEY_BATCH_STATUS_LABELS } from "@/lib/honey-batches/labels";
|
import { HONEY_BATCH_STATUS_LABELS } from "@/lib/honey-batches/labels";
|
||||||
@@ -26,7 +27,10 @@ export default function HoneyBatchesPage() {
|
|||||||
queryFn: () => fetchHoneyBatches({}),
|
queryFn: () => fetchHoneyBatches({}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const exportMutation = useMutation({ mutationFn: exportHoneyBatchesCsv });
|
const exportMutation = useMutation({
|
||||||
|
mutationFn: exportHoneyBatchesCsv,
|
||||||
|
onError: () => toast.error("CSV-Export konnte nicht heruntergeladen werden"),
|
||||||
|
});
|
||||||
|
|
||||||
const activeBatches = (honeyBatches ?? []).filter(
|
const activeBatches = (honeyBatches ?? []).filter(
|
||||||
(batch) => !HISTORY_STATUSES.includes(batch.status),
|
(batch) => !HISTORY_STATUSES.includes(batch.status),
|
||||||
|
|||||||
Reference in new issue
Block a user