restore legacy cpnp history index

This commit is contained in:
Christian Vidal Wolf
2026-05-20 15:12:36 +02:00
parent 528d859742
commit d40bc9fa9c
2 changed files with 20 additions and 2 deletions
+8 -2
View File
@@ -3,6 +3,7 @@ import { COLUMNS } from '../types';
const SUPABASE_URL = 'https://hwithddwaapyhnfwcesj.supabase.co';
const SUPABASE_ANON_KEY = 'sb_publishable_fGXkh0bSrAOqSk2jWKAzSg_NJD9YPCv';
const LEGACY_CPNP_INDEX = 77;
export async function safeFetch(url: string, options: RequestInit = {}): Promise<Response> {
const session = getStoredSession();
@@ -330,10 +331,15 @@ export async function getHistoryDataForMerge(): Promise<Record<string, ExcelRow>
// does not surface it as a changed index.
const latestCpnp =
entry.new_data?.[COLUMNS.CPNP_NO] ??
entry.new_data?.[LEGACY_CPNP_INDEX] ??
entry.old_data?.[COLUMNS.CPNP_NO];
const fallbackCpnp =
latestCpnp !== undefined && latestCpnp !== null && latestCpnp !== ''
? latestCpnp
: entry.old_data?.[LEGACY_CPNP_INDEX];
if (latestCpnp !== undefined && latestCpnp !== null && latestCpnp !== '') {
target[COLUMNS.CPNP_NO] = latestCpnp;
if (fallbackCpnp !== undefined && fallbackCpnp !== null && fallbackCpnp !== '') {
target[COLUMNS.CPNP_NO] = fallbackCpnp;
}
}