import getMe from "@/lib/getMe";
import hasPermissions from "@/lib/hasPermissions";
import { redirect } from "next/navigation";
import ShortcodesPage from "./_shortcodes";

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

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