feat: Implement admin dashboard with user management, statistics, and role-based access control.

This commit is contained in:
Yusuf İpek
2026-02-20 15:17:32 +03:00
parent 1bb1c8e574
commit 83eeffe5c0
10 changed files with 685 additions and 5 deletions
+34
View File
@@ -0,0 +1,34 @@
import { NextResponse } from 'next/server';
import { db } from '@/lib/db';
import { auth } from '@/lib/auth';
export async function GET() {
try {
const session = await auth();
if (!session?.user?.isAdmin) {
return new NextResponse('Unauthorized', { status: 403 });
}
const users = await db.user.findMany({
orderBy: { createdAt: 'desc' },
select: {
id: true,
name: true,
email: true,
createdAt: true,
_count: {
select: {
ownedWorkspaces: true,
projects: true,
comments: true,
}
}
}
});
return NextResponse.json({ users });
} catch (error) {
console.error('[ADMIN_USERS_GET]', error);
return new NextResponse('Internal Error', { status: 500 });
}
}