"use server";
import getMe from "@/lib/getMe";
import hasPermissions from "@/lib/hasPermissions";
import { redirect } from "next/navigation";
import PlanningPage from "./_planning";

export default async function Page() {
	const me = await getMe();
	if (
		!me ||
		me.status === "Error" ||
		!me.data ||
		!hasPermissions(me.data.roles, {
			events: ["get"],
		})
	) {
		redirect("/dashboard");
	}

	return <PlanningPage user={me.data} />;
}
