import { redirect } from "next/navigation";
import { getServerSession } from "next-auth";
import { AuthOptions } from "@/app/api/auth/[...nextauth]/authOptions";
import PortfolioLogs from "./PortfolioLogs";

export default async function LogsPage(props: {
  params: Promise<{ slug: string }>;
}) {
  const { slug } = await props.params;
  const session = await getServerSession(AuthOptions);
  const isDomnaUser = !!session?.user?.email?.endsWith("@domna.homes");

  if (!isDomnaUser) {
    redirect(`/portfolio/${slug}/settings/general`);
  }

  return (
    <div>
      <PortfolioLogs portfolioId={slug} />
    </div>
  );
}
