import { getCards, getPortals } from '@/lib/db';
import PublicGrid from '@/components/PublicGrid';
import HeroBanner from '@/components/HeroBanner';

export const dynamic = 'force-dynamic'; 

export default async function PublicHomePage() {
  const portals = await getPortals();
  const cards = await getCards();
  const portal = portals[0] || {};

  return (
    <main className="min-h-screen bg-gray-100 font-sans">
      <HeroBanner portal={portal} />
      <div className="max-w-[1600px] mx-auto py-12 px-4">
         {cards.length > 0 ? (
           <PublicGrid cards={cards} maxCols={portal.maxGridColumns || 5} />
         ) : (
           <div className="text-center text-gray-500 py-20">
             <p>No cards have been added yet.</p>
           </div>
         )}
      </div>
    </main>
  );
}