refresh macchneTree dopo eliminazione articolo-macchina
All checks were successful
Deploy to VPS / build (push) Successful in 40s
Deploy to VPS / deploy (push) Successful in 28s

This commit is contained in:
AV77web 2026-05-31 13:09:47 +02:00
parent ba18adf21b
commit 20443de0ab
2 changed files with 12 additions and 0 deletions

View file

@ -119,6 +119,7 @@ export default function ArticlesList() {
setMovimentoArticle(null);
fetchArticles();
fetchGiacenze();
window.dispatchEvent(new CustomEvent("articoli-updated"));
};
const filteredArticles = articles.filter((article) => {

View file

@ -95,6 +95,17 @@ export default function MacchineTree() {
loadInitialData();
}, [loadInitialData]);
useEffect(() => {
const handleArticoliUpdated = () => {
fetchArticoliPerMacchina();
};
window.addEventListener("articoli-updated", handleArticoliUpdated);
return () => {
window.removeEventListener("articoli-updated", handleArticoliUpdated);
};
}, [fetchArticoliPerMacchina]);
const getParentStabilimento = (parentId: number | null): number | null => {
if (!parentId) return null;
const parent = nodes.find((n) => n.id === parentId);