import { redirect } from 'next/navigation'
import { getServerSession } from '@/lib/auth'
import { getUserSettings } from '@/lib/settings'
import SettingsForm from './SettingsForm'

export default async function SettingsPage() {
  const session = await getServerSession()
  if (!session.userId) redirect('/login')

  const settings = getUserSettings(session.userId)

  return (
    <div className="p-6 max-w-2xl">
      <h1 className="text-2xl font-semibold mb-1" style={{ color: 'var(--text-primary)' }}>
        Settings
      </h1>
      <p className="text-sm mb-8" style={{ color: 'var(--text-secondary)' }}>
        Signed in as <strong>{session.username}</strong>
      </p>

      <h2 className="text-base font-semibold mb-4" style={{ color: 'var(--text-primary)' }}>
        Video Playback
      </h2>
      <SettingsForm initialSettings={settings} />
    </div>
  )
}
