feat(config): alta de usuarios desde Configuraciones (POST /config/usuarios, solo admin)
This commit is contained in:
@@ -108,6 +108,29 @@ export async function patchUsuarioConfig(
|
||||
if (!resp.ok) throw new Error(`HTTP ${resp.status}`)
|
||||
}
|
||||
|
||||
/** POST /config/usuarios — dar de alta un usuario (solo admin) */
|
||||
export async function crearUsuarioConfig(data: {
|
||||
nombre: string
|
||||
rol: string
|
||||
asignacion: string | null
|
||||
password: string
|
||||
}): Promise<UsuarioConfig> {
|
||||
const resp = await fetch(
|
||||
`${API_URL}/config/usuarios`,
|
||||
conAuth({
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
}),
|
||||
)
|
||||
manejar401(resp)
|
||||
if (!resp.ok) {
|
||||
const cuerpo = (await resp.json().catch(() => null)) as { error?: string } | null
|
||||
throw new Error(cuerpo?.error ?? `HTTP ${resp.status}`)
|
||||
}
|
||||
return (await resp.json()) as UsuarioConfig
|
||||
}
|
||||
|
||||
// ─── Auditoría ─────────────────────────────────────────────────
|
||||
|
||||
export interface AuditoriaItem {
|
||||
|
||||
Reference in New Issue
Block a user