import { prisma } from '@/lib/prisma';
import AcaraTable from '@/components/admin/acara-table';

export const dynamic = 'force-dynamic';
export const revalidate = 0;

export default async function AdminAcaraPage() {
    let acara: any[] = [];
    if (prisma.acara && typeof prisma.acara.findMany === 'function') {
        acara = await prisma.acara.findMany({
            orderBy: { createdAt: 'desc' },
        });
    } else {
        try {
            acara = await prisma.$queryRaw`SELECT * FROM Acara ORDER BY createdAt DESC`;
        } catch (e) {}
    }

    return (
        <div className="space-y-6">
            <AcaraTable initialData={acara || []} />
        </div>
    );
}
