diff --git a/components/timeshift-spreadsheet.tsx b/components/timeshift-spreadsheet.tsx index 813940c..3c136cc 100644 --- a/components/timeshift-spreadsheet.tsx +++ b/components/timeshift-spreadsheet.tsx @@ -365,6 +365,19 @@ export function TimeshiftSpreadsheet({ teamId, teamName }: TimeshiftSpreadsheetP styles["A23"] = "font-weight: bold;" // "Pohotovost IT" } + // Validate configuration before initializing + if (!data || data.length === 0) { + console.error("Data is empty or undefined:", data) + isInitializingRef.current = false + return + } + + if (!columns || columns.length === 0) { + console.error("Columns is empty or undefined:", columns) + isInitializingRef.current = false + return + } + console.log("Initializing jspreadsheet with config:", { dataRows: data.length, dataCols: data[0]?.length, @@ -372,9 +385,9 @@ export function TimeshiftSpreadsheet({ teamId, teamName }: TimeshiftSpreadsheetP stylesCount: Object.keys(styles).length }) - jspreadsheetInstance.current = (jexcelLib as (el: HTMLElement, config: unknown) => unknown)(spreadsheetRef.current, { - data: data, - columns: columns, + const config = { + data: data || [], + columns: columns || [], minDimensions: [data[0]?.length || 8, Math.max(data.length + 3, 10)], allowInsertRow: true, allowInsertColumn: false, @@ -384,7 +397,7 @@ export function TimeshiftSpreadsheet({ teamId, teamName }: TimeshiftSpreadsheetP tableOverflow: true, tableWidth: "100%", tableHeight: "500px", - style: styles, + style: styles || {}, onchange: (instance: any, cell: HTMLElement, x: number, y: number, value: string) => { console.log("onChange triggered:", { x, y, value, isMerging: isMergingRef.current }) @@ -501,9 +514,19 @@ export function TimeshiftSpreadsheet({ teamId, teamName }: TimeshiftSpreadsheetP }) } } - }) + } - console.log("jspreadsheet initialized:", !!jspreadsheetInstance.current) + console.log("Config validation passed, creating jspreadsheet instance...") + + try { + jspreadsheetInstance.current = (jexcelLib as (el: HTMLElement, config: unknown) => unknown)(spreadsheetRef.current, config) + console.log("jspreadsheet initialized:", !!jspreadsheetInstance.current) + } catch (error) { + console.error("Error initializing jspreadsheet:", error) + console.error("Config that caused error:", config) + isInitializingRef.current = false + return + } // Additional event listener for first row rotation as fallback setTimeout(() => { diff --git a/logs/auto-commit.log b/logs/auto-commit.log index ab3ea79..0e90643 100644 --- a/logs/auto-commit.log +++ b/logs/auto-commit.log @@ -173,3 +173,6 @@ 2025-07-30 11:54:37 +02:00: 🔖 Creating restore point... 2025-07-30 11:54:53 +02:00: ✅ Restore point created 2025-07-30 12:24:37 +02:00: 🔖 Creating restore point... +2025-07-30 12:26:09 +02:00: ✅ Restore point created +2025-07-30 12:54:37 +02:00: 🔄 Hourly reset: Commit counter reset to 0 +2025-07-30 12:54:37 +02:00: 🔖 Creating restore point... diff --git a/logs/auto-commit.out.log b/logs/auto-commit.out.log index 1ade31b..d16704f 100644 --- a/logs/auto-commit.out.log +++ b/logs/auto-commit.out.log @@ -169,3 +169,6 @@ 2025-07-30 11:54:37 +02:00: 🔖 Creating restore point... 2025-07-30 11:54:53 +02:00: ✅ Restore point created 2025-07-30 12:24:37 +02:00: 🔖 Creating restore point... +2025-07-30 12:26:09 +02:00: ✅ Restore point created +2025-07-30 12:54:37 +02:00: 🔄 Hourly reset: Commit counter reset to 0 +2025-07-30 12:54:37 +02:00: 🔖 Creating restore point...