import { supabaseAdmin } from '@/lib/supabaseAdmin'
import LogsTabs from './LogsTabs'

export default async function LogsPage() {
  const [{ data: crashes }, { data: licenseEvents }] = await Promise.all([
    supabaseAdmin
      .from('crash_reports')
      .select('id, event_type, severity, error_name, error_message, module, app_version, os, device_id, created_at')
      .order('created_at', { ascending: false })
      .limit(50),
    supabaseAdmin
      .from('license_events')
      .select('id, event_type, license_id, device_id, ip_address, app_version, created_at')
      .order('created_at', { ascending: false })
      .limit(50),
  ])

  return (
    <div className="space-y-6">
      <div>
        <h2 className="text-2xl font-bold tracking-tight text-gray-900 dark:text-white">Loglar</h2>
        <p className="text-gray-500 dark:text-gray-400 mt-2">Son 50 hata kaydı ve lisans olayı.</p>
      </div>

      <LogsTabs crashes={crashes || []} licenseEvents={licenseEvents || []} />
    </div>
  )
}
