refresh macchneTree dopo eliminazione articolo-macchina
This commit is contained in:
parent
ba18adf21b
commit
20443de0ab
2 changed files with 12 additions and 0 deletions
|
|
@ -119,6 +119,7 @@ export default function ArticlesList() {
|
||||||
setMovimentoArticle(null);
|
setMovimentoArticle(null);
|
||||||
fetchArticles();
|
fetchArticles();
|
||||||
fetchGiacenze();
|
fetchGiacenze();
|
||||||
|
window.dispatchEvent(new CustomEvent("articoli-updated"));
|
||||||
};
|
};
|
||||||
|
|
||||||
const filteredArticles = articles.filter((article) => {
|
const filteredArticles = articles.filter((article) => {
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,17 @@ export default function MacchineTree() {
|
||||||
loadInitialData();
|
loadInitialData();
|
||||||
}, [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 => {
|
const getParentStabilimento = (parentId: number | null): number | null => {
|
||||||
if (!parentId) return null;
|
if (!parentId) return null;
|
||||||
const parent = nodes.find((n) => n.id === parentId);
|
const parent = nodes.find((n) => n.id === parentId);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue