27 lines
671 B
TypeScript
27 lines
671 B
TypeScript
// app/admin/users/[userId]/page.tsx
|
|
import { getServerSession } from 'next-auth';
|
|
import { authOptions } from '@/lib/auth-options';
|
|
import { redirect } from 'next/navigation';
|
|
import UserDetailClient from './user-detail-client';
|
|
|
|
export default async function UserDetailPage({
|
|
params,
|
|
}: {
|
|
params: Promise<{ userId: string }>;
|
|
}) {
|
|
const session = await getServerSession(authOptions);
|
|
const role = (session as any)?.user?.role ?? null;
|
|
|
|
if (!session?.user) {
|
|
redirect('/login');
|
|
}
|
|
|
|
if (!(role === 'admin' || role === 'superadmin')) {
|
|
redirect('/dashboard');
|
|
}
|
|
|
|
const { userId } = await params;
|
|
|
|
return <UserDetailClient userId={userId} />;
|
|
}
|