51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import { prisma } from "@/lib/prisma";
|
|
|
|
export default async function AdminUsersPage() {
|
|
const users = await prisma.user.findMany({
|
|
orderBy: { createdAt: "desc" },
|
|
select: {
|
|
id: true,
|
|
email: true,
|
|
name: true,
|
|
role: true,
|
|
createdAt: true,
|
|
_count: { select: { enrollments: true, certificates: true } },
|
|
},
|
|
});
|
|
|
|
return (
|
|
<div>
|
|
<h1 className="page-title">Nutzer</h1>
|
|
<p className="muted subtitle">{users.length} Accounts</p>
|
|
<div className="table-wrap">
|
|
<table className="simple">
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>E-Mail</th>
|
|
<th>Rolle</th>
|
|
<th>Kurse</th>
|
|
<th>Zertifikate</th>
|
|
<th>Seit</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{users.map((u) => (
|
|
<tr key={u.id}>
|
|
<td>{u.name}</td>
|
|
<td>{u.email}</td>
|
|
<td>
|
|
<span className="badge">{u.role}</span>
|
|
</td>
|
|
<td>{u._count.enrollments}</td>
|
|
<td>{u._count.certificates}</td>
|
|
<td className="muted">{u.createdAt.toLocaleDateString("de-DE")}</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|