Files
ld-sysinfo-frontend/src/app/(protected)/admin/users/page.tsx
Bailey Taylor 868d52e224
All checks were successful
Deploy Frontend / deploy (push) Successful in 23s
Added editable user fields
2025-10-29 11:23:07 +08:00

38 lines
1011 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;
clientId?: number;
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'}`);
}
}