mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 14:05:25 +02:00
fix: ensure saved changes persist across app refreshes by updating status logic and merge check
This commit is contained in:
+5
-2
@@ -248,7 +248,7 @@ const articleNoIdx = resolvedCols.ARTICLE_NO;
|
||||
|
||||
// 2. For Master Data (indices < 100, like UVP/SRP), only restore if it's an active edit (pending)
|
||||
// This protects against the "Column Shift" bug where old saved indices might be wrong.
|
||||
if (synced?.status === 'pending') {
|
||||
if (synced?.status === 'pending' || synced?.status === 'edited') {
|
||||
editableColumns.forEach(idx => {
|
||||
if (idx < 100 && sourceForInternal[idx] !== undefined && sourceForInternal[idx] !== null) {
|
||||
finalRow[idx] = sourceForInternal[idx];
|
||||
@@ -551,7 +551,10 @@ const articleNoIdx = resolvedCols.ARTICLE_NO;
|
||||
|
||||
if (result.success) {
|
||||
// Also save to history
|
||||
await saveHistoryEntry(articleNo, articleName, originalData, newData, session?.user?.email || 'unknown');
|
||||
const histRes = await saveHistoryEntry(articleNo, articleName, originalData, newData, session?.user?.email || 'unknown');
|
||||
if (!histRes.success) {
|
||||
console.warn(`[handleSaveAll] History save failed for ${articleNo}:`, histRes.error);
|
||||
}
|
||||
|
||||
setRowStatuses(prev => ({ ...prev, [articleNo]: 'saved' }));
|
||||
setPendingRows(prev => {
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ export async function saveRowToSupabase(articleNo: string, rowData: ExcelRow): P
|
||||
body: JSON.stringify({
|
||||
product_id: articleNo,
|
||||
data: rowData,
|
||||
status: 'edited',
|
||||
status: 'pending',
|
||||
updated_at: new Date().toISOString()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user