All checks were successful
Deploy Frontend / deploy (push) Successful in 24s
✅ Added try-catch block around the API call ✅ Proper error logging and meaningful error messages users/page.tsx ✅ Removed unused cookies() import and call (it was already being called inside requireAuthOrRedirect()) ✅ Added try-catch block around the API call ✅ Proper error logging and meaningful error messages
37 lines
989 B
TypeScript
37 lines
989 B
TypeScript
// src/app/admin/users/page.tsx
|
|
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();
|
|
|
|
try {
|
|
const res = await axiosServer.get('/admin/users', {
|
|
headers: {
|
|
Authorization: `Bearer ${user.token}`,
|
|
},
|
|
});
|
|
|
|
const users: UserDTO[] = res.data;
|
|
|
|
return <UserTableSection initialUsers={users} />;
|
|
} catch (error) {
|
|
console.error('Failed to fetch users:', error);
|
|
throw new Error(`Failed to load users: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
}
|
|
}
|