import { auth } from '@/auth'
import { redirect } from 'next/navigation'
import { getAISettings } from '@/app/actions/ai-settings'
import { getUserSettings } from '@/app/actions/user-settings'
import { AppearanceSettingsClient } from './appearance-settings-client'

export default async function AppearanceSettingsPage() {
  const session = await auth()
  if (!session?.user) {
    redirect('/api/auth/signin')
  }

  const [aiSettings, userSettings] = await Promise.all([
    getAISettings(),
    getUserSettings()
  ])

  return (
    <AppearanceSettingsClient
      initialFontSize={aiSettings.fontSize}
      initialTheme={userSettings.theme}
      initialNotesViewMode={aiSettings.notesViewMode === 'masonry' ? 'masonry' : 'tabs'}
      initialCardSizeMode={userSettings.cardSizeMode}
    />
  )
}
