import Content from "@/components/panel/Content";
import { defineAbilitiesFor } from "@/lib/ability";
import { getUser } from "@/lib/auth";
import { redirect } from "next/navigation";

async function LayoutPanel({ children }) {
  const user = await getUser();
  const ability = defineAbilitiesFor(user);

  if (!ability.can("access", "Panel")) {
    return redirect("/");
  }

  return <Content children={children} />;
}

export default LayoutPanel;
