Initial commit - frontend
This commit is contained in:
36
src/app/(protected)/admin/users/page.tsx
Normal file
36
src/app/(protected)/admin/users/page.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
// src/app/admin/users/page.tsx
|
||||
import { cookies } from 'next/headers';
|
||||
import { requireAuthOrRedirect } from '@/lib/authServer';
|
||||
import axiosServer from '@/lib/axiosServer';
|
||||
import UserTableSection from '@/components/admin/UserTableSection';
|
||||
|
||||
|
||||
interface UserDTO {
|
||||
id: number;
|
||||
username: string;
|
||||
displayName: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
email: string;
|
||||
role: string;
|
||||
clientName: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
export default async function UserManagementPage() {
|
||||
const user = await requireAuthOrRedirect();
|
||||
const cookieStore = cookies();
|
||||
// @ts-expect-error - cookies() is not actually async, type is misleading
|
||||
const token = cookieStore.get('authToken')?.value;
|
||||
|
||||
|
||||
const res = await axiosServer.get('/admin/users', {
|
||||
headers: {
|
||||
Authorization: `Bearer ${user.token}`, // token is guaranteed to exist
|
||||
},
|
||||
});
|
||||
|
||||
const users: UserDTO[] = res.data;
|
||||
|
||||
return <UserTableSection initialUsers={users} />;
|
||||
}
|
||||
Reference in New Issue
Block a user