From 2961d3f86a6344d3641b22b30444645455b4929c Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Tue, 12 May 2026 16:03:12 +0200 Subject: [PATCH] fix: persist CPNP No. across refreshes by saving as 'edited' and restoring in merge - saveRowToSupabase now accepts optional status param (default 'pending') - CosmeticItemsView saves CPNP with status 'edited' so resetAllPendingRows does not affect it and it survives the startup merge - Re-added CPNP_NO to editableColumns so the merge restores it from Supabase Co-Authored-By: claude-flow --- src/App.tsx | 1 + src/components/CosmeticItemsView.tsx | 2 +- src/lib/supabase.ts | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 348338d..9401f12 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -206,6 +206,7 @@ export default function App() { resolvedCols.VALIDATED_NOTE, resolvedCols.PRODUCT_TYPE, resolvedCols.ITEM_TO_LOGISTIC, + resolvedCols.CPNP_NO, ]); headers.forEach((h: any, i: number) => { diff --git a/src/components/CosmeticItemsView.tsx b/src/components/CosmeticItemsView.tsx index a40af9b..fea2388 100644 --- a/src/components/CosmeticItemsView.tsx +++ b/src/components/CosmeticItemsView.tsx @@ -135,7 +135,7 @@ export function CosmeticItemsView({ data, headers, onSaveRow, onCaptureState, ro setEditingCpnp(null); onCaptureState(`Updated CPNP No. for ${articleNo}`); onSaveRow(rowIndex, newRow); - const result = await saveRowToSupabase(articleNo, newRow); + const result = await saveRowToSupabase(articleNo, newRow, 'edited'); setSavingCpnp(null); if (!result.success) { alert(`Error saving CPNP No. for ${articleNo}: ${result.error}`); diff --git a/src/lib/supabase.ts b/src/lib/supabase.ts index 05a25ce..c1fa47b 100644 --- a/src/lib/supabase.ts +++ b/src/lib/supabase.ts @@ -72,7 +72,7 @@ export async function getAllSyncedRows(): Promise> { } } -export async function saveRowToSupabase(articleNo: string, rowData: ExcelRow): Promise<{ success: boolean; error?: string }> { +export async function saveRowToSupabase(articleNo: string, rowData: ExcelRow, status: 'pending' | 'edited' | 'synced' = 'pending'): Promise<{ success: boolean; error?: string }> { try { const response = await safeFetch( `${SUPABASE_URL}/rest/v1/products`, @@ -85,7 +85,7 @@ export async function saveRowToSupabase(articleNo: string, rowData: ExcelRow): P body: JSON.stringify({ product_id: articleNo, data: rowData, - status: 'pending', + status, updated_at: new Date().toISOString() }) }