import Link from 'next/link'
import { redirect } from 'next/navigation'
import { getCurrentUser } from '@/lib/session'

export const dynamic = 'force-dynamic'

const SETTINGS = [
  {
    href: '/settings/backups',
    title: 'Backups',
    desc: 'Postgres dumps en restore-runbook',
  },
]

export default async function SettingsIndex() {
  const user = await getCurrentUser()
  if (!user) redirect('/login')

  return (
    <div className="min-h-screen bg-background p-6">
      <div className="mx-auto max-w-6xl space-y-6">
        <div>
          <h1 className="text-2xl font-semibold tracking-tight">Settings</h1>
          <p className="text-sm text-muted-foreground">Configuratie en onderhoud</p>
        </div>
        <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
          {SETTINGS.map((s) => (
            <Link
              key={s.href}
              href={s.href}
              className="block rounded-lg border bg-card p-5 transition-colors hover:bg-accent"
            >
              <h2 className="text-lg font-medium">{s.title}</h2>
              <p className="mt-1 text-sm text-muted-foreground">{s.desc}</p>
            </Link>
          ))}
        </div>
      </div>
    </div>
  )
}
