fix(users): handle {data, total} response shape from listUsers API

The backend returns { data: User[], total: number } but the frontend
was treating usersData directly as User[], causing filteredUsers.map
to throw 'not a function' when the page loaded.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-07 02:46:04 -08:00
parent 60cf49432e
commit 67691fc24d
1 changed files with 4 additions and 2 deletions

View File

@ -24,7 +24,7 @@ interface User {
createdAt: string;
}
type UsersResponse = User[];
type UsersResponse = { data: User[]; total: number } | User[];
interface UserFormData {
displayName: string;
@ -484,7 +484,9 @@ export default function UsersPage() {
queryFn: () => apiClient<UsersResponse>('/api/v1/auth/users'),
});
const allUsers = usersData?? [];
const allUsers: User[] = Array.isArray(usersData)
? usersData
: (usersData as { data: User[] } | undefined)?.data ?? [];
// Filter ---------------------------------------------------------------
const filteredUsers = useMemo(() => {