fix(ui): подтверждать удаление пользователя и сохранять ошибку
This commit is contained in:
1 parent
2d5fb3598f
commit
02ca48ef9c
8 files changed
+92
-23
No files matched your search
+4
-3
@@ -10,7 +10,7 @@ import {
|
||||
type UserBindingCreate,
|
||||
} from "@mmapp/contracts/users"
|
||||
import { z } from "zod"
|
||||
import { requestJson } from "@/shared/api/http-client"
|
||||
import { requestJson, requestBlob } from "@/shared/api/http-client"
|
||||
import type { AppUser, CatalogIface, InterfaceBinding } from "@/lib/users"
|
||||
|
||||
const usersListPayload = z.object({ users: z.array(appUserReadSchema).refine(rows => new Set(rows.map(row => row.id)).size === rows.length, "Повторяющиеся пользователи в ответе API") })
|
||||
@@ -71,8 +71,9 @@ export async function updateAppUser(baseUrl: string, id: string, data: AppUserUp
|
||||
return toFrontendUser(userPayload.parse(payload).user)
|
||||
}
|
||||
|
||||
export async function deleteAppUser(baseUrl: string, id: string): Promise<void> {
|
||||
await requestJson<void>(baseUrl, `/api/users/${id}`, { method: "DELETE" })
|
||||
export async function deleteAppUser(baseUrl: string, id: string, init?: RequestInit): Promise<void> {
|
||||
const response = await requestBlob(baseUrl, "/api/users/" + encodeURIComponent(id), { ...init, method: "DELETE" })
|
||||
if (response.status !== 204) throw new Error("Удаление пользователя не подтверждено: ожидается HTTP 204.")
|
||||
}
|
||||
|
||||
export async function createUserBinding(
|
||||
|
||||
Reference in new issue
Block a user