web sitesi yönetimi

This commit is contained in:
2026-01-25 01:46:12 +03:00
parent 6e56b1e75f
commit 0fe49b5c96
15 changed files with 575 additions and 155 deletions

View File

@@ -0,0 +1,45 @@
'use server'
import { createClient } from "@/lib/supabase-server"
import { SiteContent } from "@/types/cms"
import { revalidatePath } from "next/cache"
export async function updateSiteContent(contents: SiteContent[]) {
const supabase = await createClient()
try {
const { data: { user } } = await supabase.auth.getUser()
if (!user) {
return { success: false, error: "Oturum açmanız gerekiyor" }
}
// Upsert each content item
// Since we might have many items, we can do this in parallel or a single upsert if the structure allows
// Supabase upsert accepts an array
const { error } = await supabase
.from('site_contents')
.upsert(
contents.map(item => ({
key: item.key,
value: item.value,
type: item.type,
section: item.section,
updated_at: new Date().toISOString()
}))
)
if (error) {
console.error('CMS Update Error:', error)
return { success: false, error: "Güncelleme sırasında bir hata oluştu: " + error.message }
}
revalidatePath('/dashboard/cms/content')
revalidatePath('/') // Revalidate home page as it likely uses these settings
return { success: true }
} catch (error) {
console.error('CMS Update Error:', error)
return { success: false, error: "Bir hata oluştu" }
}
}