feat: update Dropbox source URL and implement smart dirty-checking for row highlight

This commit is contained in:
Christian Vidal Wolf
2026-04-21 08:55:50 +02:00
parent 964bb62838
commit 3462ac9991
+37 -12
View File
@@ -318,23 +318,48 @@ export default function App() {
const handleSaveRow = (rowIndex: number, updatedRow: ExcelRow) => { const handleSaveRow = (rowIndex: number, updatedRow: ExcelRow) => {
const articleNo = String(updatedRow[COLUMNS.ARTICLE_NO]); const articleNo = String(updatedRow[COLUMNS.ARTICLE_NO]);
const originalData = appState.data[rowIndex]; // Capture before update const currentPending = pendingRows[articleNo];
const originalData = currentPending?.originalData ?? appState.data[rowIndex];
// Check if the new state is actually different from the original (not the current)
const isActuallyModified = JSON.stringify(updatedRow) !== JSON.stringify(originalData);
setAppState(prev => { setAppState(prev => {
const newData = [...prev.data]; const newData = [...prev.data];
newData[rowIndex] = updatedRow; newData[rowIndex] = updatedRow;
return { ...prev, data: newData, hasUnsavedChanges: true }; return { ...prev, data: newData, hasUnsavedChanges: true };
}); });
setPendingRows(prev => ({
...prev, if (isActuallyModified) {
[articleNo]: { setPendingRows(prev => {
rowIndex, const next = {
// Keep the very first originalData if already pending (re-edit case) ...prev,
originalData: prev[articleNo]?.originalData ?? originalData, [articleNo]: {
newData: updatedRow, rowIndex,
articleName: String(updatedRow[COLUMNS.ARTICLE_NAME] || articleNo), originalData,
} newData: updatedRow,
})); articleName: String(updatedRow[COLUMNS.ARTICLE_NAME] || articleNo),
setRowStatuses(prev => ({ ...prev, [articleNo]: 'pending' })); }
};
setAppState(app => ({ ...app, hasUnsavedChanges: true }));
return next;
});
setRowStatuses(prev => ({ ...prev, [articleNo]: 'pending' }));
} else {
// It was changed back to its original state - remove from pending
setPendingRows(prev => {
const n = { ...prev };
delete n[articleNo];
const stillHasChanges = Object.keys(n).length > 0;
setAppState(app => ({ ...app, hasUnsavedChanges: stillHasChanges }));
return n;
});
setRowStatuses(prev => {
const n = { ...prev };
delete n[articleNo];
return n;
});
}
setEditingRowIndex(null); setEditingRowIndex(null);
}; };