import { createSupabaseServerClient } from "@/lib/supabase/server"
import { ReaderShell } from "./_components/reader-shell"

export default async function ReaderPage({
  searchParams,
}: {
  searchParams: Promise<{ folder?: string; feed?: string; custom_feed?: string }>
}) {
  const supabaseClient = await createSupabaseServerClient()
  const {
    data: { user },
  } = await supabaseClient.auth.getUser()

  const resolvedSearchParams = await searchParams

  return (
    <ReaderShell
      userEmailAddress={user?.email ?? null}
      feedFilter="all"
      folderIdentifier={resolvedSearchParams.folder}
      feedIdentifier={resolvedSearchParams.feed}
      customFeedIdentifier={resolvedSearchParams.custom_feed}
    />
  )
}
