import { draftMode } from "next/headers";
import { TestimonialsGrid } from "../../components/TestimonialsGrid";
import { LiveTestimonialsGrid } from "../../components/LiveTestimonialsGrid";
import { getTestimonials } from "../../lib/payload";

// Payload-driven like todo-cards/newsletter/challenge's own testimonial
// grids (see Testimonials collection's "page" field) — no longer a
// hardcoded array now that "der-eine" is a valid page value there.
export async function Testimonials() {
  const { isEnabled: isPreview } = await draftMode();
  const testimonials = await getTestimonials("der-eine", { draft: isPreview });

  return isPreview ? (
    <LiveTestimonialsGrid testimonials={testimonials} />
  ) : (
    <TestimonialsGrid testimonials={testimonials} />
  );
}
