fix(ui): показывать подтверждённые каталоги пользователей
This commit is contained in:
1 parent
0a332ce341
commit
2d5fb3598f
10 files changed
+186
-53
No files matched your search
+3
-3
@@ -13,7 +13,7 @@ import { z } from "zod"
|
||||
import { requestJson } from "@/shared/api/http-client"
|
||||
import type { AppUser, CatalogIface, InterfaceBinding } from "@/lib/users"
|
||||
|
||||
const usersListPayload = z.object({ users: z.array(appUserReadSchema) })
|
||||
const usersListPayload = z.object({ users: z.array(appUserReadSchema).refine(rows => new Set(rows.map(row => row.id)).size === rows.length, "Повторяющиеся пользователи в ответе API") })
|
||||
const userPayload = z.object({ user: appUserReadSchema })
|
||||
const bindingPayload = z.object({ binding: userBindingSchema })
|
||||
const catalogPayload = z.object({ interfaces: z.array(catalogInterfaceSchema) })
|
||||
@@ -50,8 +50,8 @@ export function toFrontendUser(u: AppUserRead): AppUser {
|
||||
}
|
||||
}
|
||||
|
||||
export async function listAppUsers(baseUrl: string): Promise<AppUser[]> {
|
||||
const payload = await requestJson<unknown>(baseUrl, "/api/users")
|
||||
export async function listAppUsers(baseUrl: string, init?: RequestInit): Promise<AppUser[]> {
|
||||
const payload = await requestJson<unknown>(baseUrl, "/api/users", init)
|
||||
return usersListPayload.parse(payload).users.map(toFrontendUser)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user