fix: buttons not working

This commit is contained in:
2025-11-10 11:46:26 +01:00
parent a501bb0ca1
commit f1d5d6bfee
2 changed files with 21 additions and 13 deletions

View File

@@ -681,7 +681,7 @@ function App() {
};
}, [isDirty]);
const persistConfigUpdate = async (updater, successMessage) => {
const persistConfigUpdate = async (updater, successMessage, { autoCommit = false } = {}) => {
if (!session?.token) {
return;
}
@@ -693,6 +693,9 @@ function App() {
if (!nextConfigState) {
return;
}
if (!autoCommit) {
setIsDirty(true);
}
setStatus('Speichere...');
setError('');
try {
@@ -714,6 +717,9 @@ function App() {
setIsDirty(false);
} catch (err) {
setError(`Fehler beim Speichern: ${err.message}`);
if (autoCommit) {
setIsDirty(true);
}
}
};
@@ -727,10 +733,10 @@ function App() {
if (!confirmed) {
return;
}
setIsDirty(true);
await persistConfigUpdate(
(prev) => prev.filter((item) => item.id !== entryId),
'Eintrag gelöscht!'
'Eintrag gelöscht!',
{ autoCommit: true }
);
};
@@ -743,10 +749,10 @@ function App() {
if (!confirmed) {
return;
}
setIsDirty(true);
await persistConfigUpdate(
(prev) => prev.map((item) => (item.id === entryId ? { ...item, hidden: true } : item)),
'Betrieb ausgeblendet.'
'Betrieb ausgeblendet.',
{ autoCommit: true }
);
};
@@ -898,9 +904,7 @@ function App() {
if (!confirmed) {
return;
}
setIsDirty(true);
const message = existing ? 'Betrieb wieder eingeblendet.' : 'Betrieb zur Liste hinzugefügt.';
setIsDirty(true);
await persistConfigUpdate(
(prev) => {
const already = prev.find((item) => item.id === storeId);
@@ -927,7 +931,8 @@ function App() {
}
];
},
message
message,
{ autoCommit: true }
);
setFocusedStoreId(storeId);
};