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:
parent
60cf49432e
commit
67691fc24d
|
|
@ -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(() => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue