fix(admin): render users list contract and allowlist user projection
Deploy Canina / deploy (push) Successful in 4m37s
Deploy Canina / deploy (push) Successful in 4m37s
This commit is contained in:
1 parent
3e78b89cc1
commit
3321bac22d
4 files changed
+99
-12
No files matched your search
@@ -57,9 +57,9 @@ describe('Users Page', () => {
|
||||
vi.clearAllMocks();
|
||||
vi.mocked(api.get).mockResolvedValue({
|
||||
data: {
|
||||
success: true,
|
||||
// Actual GET /admin/users contract: no success envelope.
|
||||
data: mockUsers,
|
||||
meta: { lastPage: 2, total: 2 },
|
||||
meta: { lastPage: 2, total: 2, page: 1, limit: 10 },
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -260,9 +260,8 @@ describe('Users Page', () => {
|
||||
it('renders empty table state when no users are returned', async () => {
|
||||
vi.mocked(api.get).mockResolvedValueOnce({
|
||||
data: {
|
||||
success: true,
|
||||
data: [],
|
||||
meta: { lastPage: 1, total: 0 },
|
||||
meta: { lastPage: 1, total: 0, page: 1, limit: 10 },
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -179,7 +179,8 @@ export default function Users() {
|
||||
if (role) params.append('role', role);
|
||||
|
||||
const response = await api.get(`/admin/users?${params.toString()}`);
|
||||
if (response.data?.success) {
|
||||
// The list endpoint returns { data, meta }, not a success envelope.
|
||||
if (Array.isArray(response.data?.data)) {
|
||||
const userList = response.data.data || [];
|
||||
setUsers(userList);
|
||||
setTotalPages(response.data.meta?.lastPage || 1);
|
||||
|
||||
Reference in new issue
Block a user