import { createClient } from "@/lib/supabase-server"
import { SiteSettingsForm } from "@/components/dashboard/site-settings-form"
import { AppearanceForm } from "@/components/dashboard/appearance-form"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"

import { Button } from "@/components/ui/button"

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

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

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

            {/* Site General Settings */}
            <div className="grid gap-4">
                <SiteSettingsForm initialData={settings} />
            </div>

            <div className="grid gap-4 grid-cols-1 md:grid-cols-2">
                <AppearanceForm />

                <Card>
                    <CardHeader>
                        <CardTitle>Hesap Güvenliği</CardTitle>
                        <CardDescription>
                            Şifre ve oturum yönetimi.
                        </CardDescription>
                    </CardHeader>
                    <CardContent className="space-y-4">
                        <Button variant="outline" className="w-full">Şifre Değiştir</Button>
                        <Button variant="destructive" className="w-full">Hesabı Sil</Button>
                    </CardContent>
                </Card>
            </div>
        </div>
    )
}
