import type { Metadata } from "next";
import { headers } from "next/headers";
import { auth } from "@/lib/auth/server";
import { db, userFollows, eq } from "@epicure/db";
import { FeedPageContent } from "@/components/feed/feed-page-content";

export const metadata: Metadata = {};

export default async function FeedPage() {
  const session = await auth.api.getSession({ headers: await headers() });
  if (!session) return null;

  const followedRows = await db
    .select({ followingId: userFollows.followingId })
    .from(userFollows)
    .where(eq(userFollows.followerId, session.user.id));

  return <FeedPageContent followedCount={followedRows.length} />;
}
