diff --git a/resources/js/components/transactions/transaction-list.tsx b/resources/js/components/transactions/transaction-list.tsx index 593566ee..2bc6765d 100644 --- a/resources/js/components/transactions/transaction-list.tsx +++ b/resources/js/components/transactions/transaction-list.tsx @@ -146,6 +146,10 @@ function TransactionRowComponent({ } function getInitialColumnVisibility(): VisibilityState { + if (typeof window === 'undefined') { + return { account: false }; + } + try { const stored = localStorage.getItem(COLUMN_VISIBILITY_KEY); if (stored) { diff --git a/resources/js/hooks/use-appearance.tsx b/resources/js/hooks/use-appearance.tsx index 9679ac98..c4270d92 100644 --- a/resources/js/hooks/use-appearance.tsx +++ b/resources/js/hooks/use-appearance.tsx @@ -20,6 +20,8 @@ const setCookie = (name: string, value: string, days = 365) => { }; const applyTheme = (appearance: Appearance) => { + if (typeof document === 'undefined') return; + const isDark = appearance === 'dark' || (appearance === 'system' && prefersDark()); @@ -36,11 +38,15 @@ const mediaQuery = () => { }; const handleSystemThemeChange = () => { + if (typeof window === 'undefined') return; + const currentAppearance = localStorage.getItem('appearance') as Appearance; applyTheme(currentAppearance || 'system'); }; export function initializeTheme() { + if (typeof window === 'undefined') return; + const savedAppearance = (localStorage.getItem('appearance') as Appearance) || 'system'; diff --git a/resources/js/lib/balance-import-config-storage.ts b/resources/js/lib/balance-import-config-storage.ts index 0e3ec2b4..4c386f99 100644 --- a/resources/js/lib/balance-import-config-storage.ts +++ b/resources/js/lib/balance-import-config-storage.ts @@ -13,6 +13,8 @@ export function saveBalanceImportConfig( accountId: UUID, config: BalanceImportConfig, ): void { + if (typeof window === 'undefined') return; + try { const key = `${STORAGE_KEY_PREFIX}${accountId}`; localStorage.setItem(key, JSON.stringify(config)); @@ -24,6 +26,8 @@ export function saveBalanceImportConfig( export function loadBalanceImportConfig( accountId: UUID, ): BalanceImportConfig | null { + if (typeof window === 'undefined') return null; + try { const key = `${STORAGE_KEY_PREFIX}${accountId}`; const stored = localStorage.getItem(key); @@ -46,6 +50,8 @@ export function loadBalanceImportConfig( } export function clearBalanceImportConfig(accountId: UUID): void { + if (typeof window === 'undefined') return; + try { const key = `${STORAGE_KEY_PREFIX}${accountId}`; localStorage.removeItem(key); diff --git a/resources/js/lib/import-config-storage.ts b/resources/js/lib/import-config-storage.ts index b68b2f3c..52dfe1d6 100644 --- a/resources/js/lib/import-config-storage.ts +++ b/resources/js/lib/import-config-storage.ts @@ -11,6 +11,8 @@ export function saveImportConfig( accountId: number, config: ImportConfig, ): void { + if (typeof window === 'undefined') return; + try { const key = `${STORAGE_KEY_PREFIX}${accountId}`; localStorage.setItem(key, JSON.stringify(config)); @@ -20,6 +22,8 @@ export function saveImportConfig( } export function loadImportConfig(accountId: number): ImportConfig | null { + if (typeof window === 'undefined') return null; + try { const key = `${STORAGE_KEY_PREFIX}${accountId}`; const stored = localStorage.getItem(key); @@ -42,6 +46,8 @@ export function loadImportConfig(accountId: number): ImportConfig | null { } export function clearImportConfig(accountId: number): void { + if (typeof window === 'undefined') return; + try { const key = `${STORAGE_KEY_PREFIX}${accountId}`; localStorage.removeItem(key); diff --git a/resources/js/pages/transactions/index.tsx b/resources/js/pages/transactions/index.tsx index e1db15d7..3aea133a 100644 --- a/resources/js/pages/transactions/index.tsx +++ b/resources/js/pages/transactions/index.tsx @@ -157,6 +157,10 @@ function TransactionRowComponent({ } function getInitialColumnVisibility(): VisibilityState { + if (typeof window === 'undefined') { + return { account: false }; + } + try { const stored = localStorage.getItem(COLUMN_VISIBILITY_KEY); if (stored) {