import { createClient } from "@/lib/supabase-server"
import { SettingsTabs } from "@/components/dashboard/settings-tabs"
import { getSmsSettings } from "@/lib/sms/actions"

export default async function SettingsPage() {
    const supabase = createClient()

    // Fetch site settings
    const { data: siteSettings } = await supabase
        .from('site_settings')
        .select('*')
        .single()

    // Fetch SMS settings (server-side call to our action/db)
    // Note: getSmsSettings is an action that checks for admin, which is fine.
    // However, since we are in a server component with a Supabase client, we could also fetch directly if we had admin client.
    // But let's use the clean action or direct logic.
    // Actually, calling server action from server component is fine, but we need to handle the return structure.
    const smsResponse = await getSmsSettings()
    const smsSettings = smsResponse.data || null

    return (
        <div className="flex-1 space-y-4 p-8 pt-6">
            <h2 className="text-3xl font-bold tracking-tight">Ayarlar</h2>
            <SettingsTabs siteSettings={siteSettings} smsSettings={smsSettings} />
        </div>
    )
}
