"use server";
import MembersTable from "@/components/members-table";
import getMe from "@/lib/getMe";
import hasPermissions from "@/lib/hasPermissions";
import { redirect } from "next/navigation";

export default async function Page({}) {
	const me = await getMe();
	if (
		!me ||
		me.status === "Error" ||
		!me.data ||
		!hasPermissions(me.data.roles, {
			users: ["get"],
		} as const).all
	) {
		redirect("/dashboard");
	}
	return (
		<div className="container mx-auto px-4 py-10">
			<MembersTable user={me.data} />
		</div>
	);
}
