fix duplicate

This commit is contained in:
2026-03-28 17:41:46 +01:00
parent 9424b44fd9
commit 1f8b28cf8e
+11 -4
View File
@@ -434,10 +434,17 @@ function duplicateLastMonth(lastMonthDate, owner) {
formData.append("owner", owner); formData.append("owner", owner);
fetch("/modules/budget/includes/api/save-savings.php", { method: "POST", body: formData }) fetch("/modules/budget/includes/api/save-savings.php", { method: "POST", body: formData })
.then(r => r.json()) .then(async r => {
.then(d => { const text = await r.text(); // On lit en texte brut d'abord
if (d.success) window.location.reload(); try {
else alert("Erreur serveur : " + (d.error || "Inconnue")); const d = JSON.parse(text); // On essaie de parser en JSON
if (d.success) window.location.reload();
else alert("Erreur serveur : " + (d.error || "Inconnue"));
} catch(e) {
// Si ça plante (HTML, redirection, erreur PHP masquée), on force le rechargement
console.log("Avertissement : La réponse serveur n'était pas du JSON. Rechargement...");
window.location.reload();
}
}) })
.catch(err => { .catch(err => {
console.error(err); console.error(err);