diff --git a/app/admin/settings/page.tsx b/app/admin/settings/page.tsx index c059329..212068e 100644 --- a/app/admin/settings/page.tsx +++ b/app/admin/settings/page.tsx @@ -1,138 +1,188 @@ 'use client'; -import React from 'react'; -import { - Globe, - ShieldCheck, - Bell, - Trash2, - Smartphone, - Monitor, +import React, { useState, useEffect } from 'react'; +import { + Zap, + ShieldCheck, + Save, + RefreshCcw, + Wallet, + Settings, + Server, + Key, + AlertCircle } from 'lucide-react'; -export default function SettingsPage() { +export default function AdminSettingsPage() { + const [settings, setSettings] = useState({ + sol_platform_address: '', + evm_platform_address: '' + }); + const [isLoading, setIsLoading] = useState(true); + const [isSaving, setIsSaving] = useState(false); + const [message, setMessage] = useState({ type: '', text: '' }); + + useEffect(() => { + fetchSettings(); + }, []); + + const fetchSettings = async () => { + setIsLoading(true); + try { + const res = await fetch('/api/admin/settings'); + const data = await res.json(); + if (data.error) throw new Error(data.error); + setSettings({ + sol_platform_address: data.sol_platform_address || '', + evm_platform_address: data.evm_platform_address || '' + }); + } catch (err: any) { + setMessage({ type: 'error', text: 'Ayarlar yüklenemedi: ' + err.message }); + } finally { + setIsLoading(false); + } + }; + + const handleSave = async (e: React.FormEvent) => { + e.preventDefault(); + setIsSaving(true); + setMessage({ type: '', text: '' }); + + try { + const res = await fetch('/api/admin/settings', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(settings) + }); + const data = await res.json(); + if (data.error) throw new Error(data.error); + setMessage({ type: 'success', text: 'Ayarlar başarıyla güncellendi.' }); + } catch (err: any) { + setMessage({ type: 'error', text: 'Kaydetme hatası: ' + err.message }); + } finally { + setIsSaving(false); + } + }; + return ( -
Platform tercihlerinizi yönetin
+Sistem Genel Yapılandırması
+