import { auth } from "@/auth";
import { hasPermission } from "@/lib/permissions";
import { redirect } from "next/navigation";
import { CompanyForm } from "../company-form";
import type { Metadata } from "next";

export const metadata: Metadata = { title: "Add Company" };

export default async function NewCompanyPage() {
  const session = await auth();
  if (!session?.user) redirect("/login");
  if (!hasPermission(session.user.role, "manage_vessels_accounts")) redirect("/dashboard");

  return <CompanyForm />;
}
