fix: add debug logs to handleSaveAll to diagnose save issue

This commit is contained in:
Christian Vidal Wolf
2026-04-10 10:45:11 +02:00
parent bb1af0dbbd
commit 0139e1de20
+9 -1
View File
@@ -289,12 +289,18 @@ export default function App() {
}; };
const handleSaveAll = async () => { const handleSaveAll = async () => {
console.log('[handleSaveAll] Starting save, pendingRows:', pendingRows);
const entries = Object.entries(pendingRows) as [string, { rowIndex: number; originalData: ExcelRow; newData: ExcelRow; articleName: string }][]; const entries = Object.entries(pendingRows) as [string, { rowIndex: number; originalData: ExcelRow; newData: ExcelRow; articleName: string }][];
if (entries.length === 0) return; if (entries.length === 0) {
console.log('[handleSaveAll] No entries to save, returning');
return;
}
setIsSavingAll(true); setIsSavingAll(true);
let allSuccess = true; let allSuccess = true;
for (const [articleNo, { newData, originalData, articleName }] of entries) { for (const [articleNo, { newData, originalData, articleName }] of entries) {
console.log('[handleSaveAll] Saving article:', articleNo);
const success = await saveRowToSupabase(articleNo, newData); const success = await saveRowToSupabase(articleNo, newData);
console.log('[handleSaveAll] Save result for', articleNo, ':', success);
if (success) { if (success) {
// Also save to history // Also save to history
await saveHistoryEntry(articleNo, articleName, originalData, newData, session?.user?.email || 'unknown'); await saveHistoryEntry(articleNo, articleName, originalData, newData, session?.user?.email || 'unknown');
@@ -306,8 +312,10 @@ export default function App() {
allSuccess = false; allSuccess = false;
} }
} }
console.log('[handleSaveAll] Finished, allSuccess:', allSuccess);
if (allSuccess) setAppState(prev => ({ ...prev, hasUnsavedChanges: false })); if (allSuccess) setAppState(prev => ({ ...prev, hasUnsavedChanges: false }));
setIsSavingAll(false); setIsSavingAll(false);
console.log('[handleSaveAll] isSavingAll set to false');
}; };
const captureState = (message: string) => { const captureState = (message: string) => {