import { auth } from "@/auth";
import { getPayloadSession } from "payload-authjs";
import { getPayload } from 'payload'
import config from '@payload-config'
import { Input } from '@/components/ui/input'
import DiplomarbeitSearch from '@/app/(frontend)/_components/DiplomarbeitSearch'

const payload = await getPayload({ config })


const Page = async () => {
  const authjsSession = await auth();
  const payloadSession = await getPayloadSession();




  const media = await payload.find({
    collection: 'media',
  })

  return (
    <main>
      <div className="w-full flex justify-center pt-4">
        <div className="w-1/3 flex flex-col items-center">
          <h2 className="text-5xl w-auto  ">Alle Diplomarbeiten</h2>
          <DiplomarbeitSearch />
        </div>
      </div>

      {media.docs.map((med) => (
        <div key={med.id}>
          <h2>{med.url}</h2>
          <p>{med.alt}</p>
        </div>
      ))}
      <br />
      <h3>Auth.js Session</h3>
      <pre>{JSON.stringify(authjsSession, null, 2)}</pre>
      <br />
      <h3>Payload CMS Session</h3>
      <pre>{JSON.stringify(payloadSession, null, 2)}</pre>
    </main>
  );
};

export default Page;
