import { prisma } from '@/lib/db'; import { getSession } from '@/lib/auth'; import { redirect } from 'next/navigation'; import { Image as ImageIcon, Video, Upload } from 'lucide-react'; import { updateHeroMedia } from '../actions'; import { revalidatePath } from 'next/cache'; import { uploadImage } from '@/lib/cloudinary'; export default async function HeroAdminPage() { const session = await getSession(); if (!session) redirect('/admin/login'); const heroMediaList = await prisma.heroMedia.findMany(); const currentHero = heroMediaList.length > 0 ? heroMediaList[0] : null; return (

Hero (Ana Ekran) Yönetimi

{/* Yükleme Formu */}

Yeni Medya Yükle

{ 'use server'; const file = formData.get('media') as File; if (file && file.size > 0) { const url = await uploadImage(file); // Cloudinary returns video format URLs or we can infer from file type const type = file.type.startsWith('video/') ? 'video' : 'image'; await updateHeroMedia(url, type); revalidatePath('/admin/hero'); } }} className="space-y-4">

Yeni bir dosya yüklediğinizde, mevcut olan otomatik olarak silinir ve yerini alır. Sadece bir adet Hero medyası bulunabilir.

{/* Mevcut Medya */}

Aktif Medya

{currentHero ? (
{currentHero.type === 'video' ? (
) : (
Henüz medya yüklenmemiş. Varsayılan resim gösteriliyor.
)}
); }