import { getGalleryImages } from "@/app/actions/gallery";
import GalleryClient from "@/components/admin/GalleryClient";

export const dynamic = "force-dynamic";

export default async function GalleryPage() {
  const result = await getGalleryImages();
  const images = result.success && result.data ? result.data : [];

  // Data parsing for Client Component
  const parsedImages = images.map(img => ({
    ...img,
    createdAt: img.createdAt.toISOString(),
    updatedAt: img.updatedAt.toISOString(),
  }));

  return <GalleryClient initialImages={parsedImages as any} />;
}
