import { AdminShell } from "@/components/admin/AdminShell";
import { getServerSession } from "next-auth";
import { authOptions } from "@/lib/auth";
import { getUnreadConversationsCount } from "@/lib/conversations-queries";

export default async function AdminLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  const session = await getServerSession(authOptions);
  if (!session) {
    return <div className="min-h-screen bg-background">{children}</div>;
  }
  const unreadConversations = await getUnreadConversationsCount();
  return <AdminShell unreadConversations={unreadConversations}>{children}</AdminShell>;
}
