+
+
Stabilimenti e Magazzini
+
+ Anagrafica sedi produttive e magazzini associati
+
+
+
+
+
+
Stabilimenti
+
{stabilimenti.length}
+
+
+
Magazzini totali
+
{totalMagazzini}
+
+
+
+ {error && (
+
+ {error}
+
+
+ )}
+
+
+
setSearch(e.target.value)}
+ placeholder="Cerca stabilimenti..."
+ className="w-full md:max-w-md px-4 py-2 rounded-lg bg-zinc-900 border border-zinc-800 text-white placeholder-zinc-500 focus:outline-none focus:border-blue-500"
+ />
+
+
+
+
+
+
+ {loading ? (
+
+
+ Caricamento...
+
+ ) : filtered.length === 0 ? (
+
+
Nessuno stabilimento
+
+ {search ? "Nessun risultato per la ricerca" : "Aggiungi il primo stabilimento"}
+
+ {!search && (
+
+ )}
+
+ ) : (
+
+ {filtered.map((stab) => (
+
+
+
+
🏭
+
+
{stab.descrizione}
+
+ {stab.magazzini.length} magazzin{stab.magazzini.length === 1 ? "o" : "i"}
+
+
+
+
+
+
+
+
+
+
+
+ {stab.magazzini.length === 0 ? (
+
Nessun magazzino associato
+ ) : (
+
+ {stab.magazzini.map((mag) => (
+ -
+
+ 📦
+ {mag.descrizione}
+
+
+
+
+
+
+ ))}
+
+ )}
+
+
+ ))}
+
+ )}
+
+ {stabModal && (
+
setStabModal(null)}
+ onSubmit={handleStabilimentoSubmit}
+ submitLabel={stabModal === "edit" ? "Salva" : "Crea"}
+ >
+
+
+ setStabDescrizione(e.target.value)}
+ required
+ className="w-full px-3 py-2 rounded-lg bg-zinc-950 border border-zinc-700 text-white focus:outline-none focus:border-blue-500"
+ placeholder="Es. Stabilimento Gonzaga"
+ />
+
+
+ )}
+
+ {magModal && (
+
setMagModal(null)}
+ onSubmit={handleMagazzinoSubmit}
+ submitLabel={magModal === "edit" ? "Salva" : "Crea"}
+ >
+
+
+
+
+
+
+ setMagDescrizione(e.target.value)}
+ required
+ className="w-full px-3 py-2 rounded-lg bg-zinc-950 border border-zinc-700 text-white focus:outline-none focus:border-blue-500"
+ placeholder="Es. Magazzino ricambi"
+ />
+
+
+ )}
+
+ );
+}
diff --git a/src/contexts/StabilimentoContext.tsx b/src/contexts/StabilimentoContext.tsx
index 32719ff..b5de2cb 100644
--- a/src/contexts/StabilimentoContext.tsx
+++ b/src/contexts/StabilimentoContext.tsx
@@ -20,6 +20,7 @@ interface StabilimentoContextValue {
setSelectedMagazzino: (magazzino: Magazzino | null) => void;
filteredMagazzini: Magazzino[];
resetSelection: () => void;
+ reload: () => Promise