'use client' import { useState } from "react" import { SiteContent } from "@/types/cms" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Textarea } from "@/components/ui/textarea" import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card" import { ImageUpload } from "@/components/ui/image-upload" // Ensure this exists or adapt import { updateSiteContent } from "@/app/(dashboard)/dashboard/cms/content/actions" import { toast } from "sonner" import { Save, Loader2 } from "lucide-react" import { cn } from "@/lib/utils" interface ContentFormProps { initialContent: SiteContent[] } const SECTIONS = [ { id: 'general', label: 'Genel Ayarlar' }, { id: 'home', label: 'Anasayfa' }, { id: 'contact', label: 'İletişim' }, { id: 'seo', label: 'SEO Ayarları' }, { id: 'scripts', label: 'Script & Analitik' }, ] export function ContentForm({ initialContent }: ContentFormProps) { const [contents, setContents] = useState(initialContent) const [loading, setLoading] = useState(false) const [activeSection, setActiveSection] = useState('general') const handleChange = (key: string, value: string) => { setContents(prev => prev.map(item => item.key === key ? { ...item, value } : item )) } const onSubmit = async () => { setLoading(true) try { const result = await updateSiteContent(contents) if (result.success) { toast.success("İçerikler başarıyla güncellendi") } else { toast.error(result.error) } } catch { toast.error("Bir hata oluştu") } finally { setLoading(false) } } const filteredContent = contents.filter(item => item.section === activeSection) return (
{/* Custom Tabs */}
{SECTIONS.map((section) => ( ))}
{SECTIONS.find(s => s.id === activeSection)?.label} Bu bölümdeki içerikleri aşağıdan düzenleyebilirsiniz. {filteredContent.length === 0 && (

Bu bölümde henüz ayar bulunmuyor.

)} {filteredContent.map((item) => (
{item.type === 'image_url' ? ( handleChange(item.key, url)} onRemove={() => handleChange(item.key, '')} /> ) : item.type === 'long_text' || item.type === 'html' || item.key.includes('address') ? (