feat(config): alta de usuarios desde Configuraciones (POST /config/usuarios, solo admin)

This commit is contained in:
2026-09-14 20:21:15 +00:00
parent 31379806be
commit b99707689f
5 changed files with 240 additions and 1 deletions

View File

@@ -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 {