import { User2 } from "lucide-react";
import { PaginatedTable } from "../../../_components/PaginatedTable";
import { getServerSession } from "api/auth/[...nextauth]/auth";

const AdminUserPage = async () => {
	const session = await getServerSession();
	return (
		<>
			<PaginatedTable
				showEditButton
				prismaModel="user"
				searchFields={["publicId", "firstname", "lastname", "email"]}
				initialOrderBy={[
					{
						id: "publicId",
						desc: false,
					},
				]}
				columns={[
					{
						header: "ID",
						accessorKey: "publicId",
					},
					{
						header: "Vorname",
						accessorKey: "firstname",
					},
					{
						header: "Nachname",
						accessorKey: "lastname",
					},
					...(session?.user.permissions.includes("ADMIN_USER_ADVANCED")
						? [
								{
									header: "Email",
									accessorKey: "email",
								},
							]
						: []),
				]}
				leftOfSearch={
					<p className="text-2xl font-semibold text-left flex items-center gap-2">
						<User2 className="w-5 h-5" /> Benutzer
					</p>
				}
			/>
		</>
	);
};

AdminUserPage.displayName = "AdminUserPage";

export default AdminUserPage;
