coorectif de refresh
This commit is contained in:
1 parent
804a40f52c
commit
9540221577
2 files changed
+45
-27
No files matched your search
@@ -196,18 +196,27 @@ export default function DepotsRetraits() {
|
||||
// Snapshots "fin d'année" du solde porte-monnaie, calculés côté backend
|
||||
// (GET /dashboard?asOf=YYYY-12-31) : année sélectionnée (si filtre actif) +
|
||||
// année précédente (toujours nécessaire pour le TrendBadge).
|
||||
useEffect(() => {
|
||||
// Extrait en fonction nommée pour pouvoir aussi être rappelée après chaque
|
||||
// mutation (remboursement, mouvement, correction) affectant le porte-monnaie —
|
||||
// `load()` seul ne suffit pas, ces snapshots vivent dans un state à part.
|
||||
const loadDashDataAsOf = async () => {
|
||||
if (!activeId && activeView !== 'all') return;
|
||||
const scopeParams = activeView === 'all' ? { scope: 'all' } : undefined;
|
||||
const prevYear = String(Number(drPlatYear || new Date().getFullYear()) - 1);
|
||||
const dates = new Set([`${prevYear}-12-31`]);
|
||||
if (drPlatYear) dates.add(`${drPlatYear}-12-31`);
|
||||
Promise.all([...dates].map(asOf =>
|
||||
api.get('/dashboard', { ...scopeParams, asOf }).then(d => [asOf, d])
|
||||
)).then(entries => {
|
||||
try {
|
||||
const entries = await Promise.all([...dates].map(asOf =>
|
||||
api.get('/dashboard', { ...scopeParams, asOf }).then(d => [asOf, d])
|
||||
));
|
||||
setDashDataAsOf(prev => ({ ...prev, ...Object.fromEntries(entries) }));
|
||||
}).catch(e => console.error('dashDataAsOf load error:', e));
|
||||
}, [drPlatYear, activeView, activeId]); // eslint-disable-line
|
||||
} catch (e) { console.error('dashDataAsOf load error:', e); }
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
loadDashDataAsOf();
|
||||
// eslint-disable-next-line
|
||||
}, [drPlatYear, activeView, activeId]);
|
||||
|
||||
// Ferme tous les menus contextuels au scroll
|
||||
useEffect(() => {
|
||||
@@ -741,7 +750,7 @@ export default function DepotsRetraits() {
|
||||
};
|
||||
if (editingId) {
|
||||
await api.put(`/depots-retraits/${editingId}`, payload);
|
||||
close(); await load();
|
||||
close(); await Promise.all([load(), loadDashDataAsOf()]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -772,7 +781,7 @@ export default function DepotsRetraits() {
|
||||
investisseurId: Number(form.investisseur_id) || null,
|
||||
});
|
||||
} else {
|
||||
await load();
|
||||
await Promise.all([load(), loadDashDataAsOf()]);
|
||||
}
|
||||
} catch (e) { setErr(e.message); }
|
||||
};
|
||||
@@ -794,7 +803,7 @@ export default function DepotsRetraits() {
|
||||
}
|
||||
}
|
||||
setCorrModal(m => ({ ...m, open: false }));
|
||||
await load();
|
||||
await Promise.all([load(), loadDashDataAsOf()]);
|
||||
};
|
||||
|
||||
const openRowMenu = (e, row) => {
|
||||
@@ -810,7 +819,7 @@ export default function DepotsRetraits() {
|
||||
await api.del(`/depots-retraits/${rowId}`);
|
||||
setDeleteConfirm(null);
|
||||
setSelectedRow(null);
|
||||
await load();
|
||||
await Promise.all([load(), loadDashDataAsOf()]);
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -822,7 +831,7 @@ export default function DepotsRetraits() {
|
||||
await api.del(`/corrections/${corrId}`);
|
||||
setDeleteConfirm(null);
|
||||
setSelectedRow(null);
|
||||
await load();
|
||||
await Promise.all([load(), loadDashDataAsOf()]);
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -834,7 +843,7 @@ export default function DepotsRetraits() {
|
||||
onConfirm: async () => {
|
||||
await api.del(`/depots-retraits/${editingId}`);
|
||||
setDeleteConfirm(null);
|
||||
close(); setSelectedRow(null); await load();
|
||||
close(); setSelectedRow(null); await Promise.all([load(), loadDashDataAsOf()]);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user