feat(frontend): CSV-Import-Seite mit Ergebnisbericht (Modul 33)
Neue Seite /settings/import (nur Administrator, Sidebar-Link unter Verwaltung): Datentyp wählen (Bienenstände/Völker/Königinnen), CSV-Datei hochladen, danach Ergebnisbericht mit Zusammenfassung (erstellt/ übersprungen/Fehler) und Zeile-für-Zeile-Tabelle inkl. Statusbadge und Fehlermeldung. Live gegen das Backend verifiziert: Upload einer CSV mit einer gültigen und einer ungültigen Zeile erzeugt korrekt 1 erstellt / 1 Fehler mit Validierungsmeldung, der neu angelegte Bienenstand erscheint danach in der regulären Bienenstände-Liste. Zero Konsolenfehler.
This commit is contained in:
1 parent
4f2f31c05f
commit
dfea017f75
4 files changed
+206
No files matched your search
@@ -0,0 +1,8 @@
|
||||
import { apiFetchFormData } from "@/lib/auth/api-client";
|
||||
import { ImportEntity, ImportReport } from "./types";
|
||||
|
||||
export function importCsv(entity: ImportEntity, file: File): Promise<ImportReport> {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
return apiFetchFormData<ImportReport>(`/import/${entity}`, formData);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
export type ImportEntity = "apiaries" | "colonies" | "queens";
|
||||
export type ImportRowStatus = "created" | "skipped" | "error";
|
||||
|
||||
export interface ImportRowResult {
|
||||
row: number;
|
||||
status: ImportRowStatus;
|
||||
message?: string;
|
||||
id?: string;
|
||||
}
|
||||
|
||||
export interface ImportReport {
|
||||
entity: ImportEntity;
|
||||
totalRows: number;
|
||||
created: number;
|
||||
skipped: number;
|
||||
errors: number;
|
||||
rows: ImportRowResult[];
|
||||
}
|
||||
Reference in new issue
Block a user