fix(alta): error 400 del servidor ya no se reporta como 'sin conexión'
- API: viviendaCredito.ubicacion ahora opcional (la app web no la exigía; el desfase causaba 400 que la app mostraba como fallo de red) - App: crearAltaCliente distingue conexion/validacion; el 400 muestra banner rojo con el detalle de los issues en vez del banner ámbar - Tests: api 160, alta-clientes 66
This commit is contained in:
@@ -16,18 +16,25 @@ export default function AltaClientePage() {
|
||||
useAltaCliente()
|
||||
const [registro, setRegistro] = useState<string>('')
|
||||
const [sinConexion, setSinConexion] = useState(false)
|
||||
const [errorValidacion, setErrorValidacion] = useState<string>('')
|
||||
|
||||
// Registra el alta en el API al llegar al paso de firmas; si el API no
|
||||
// responde, el flujo continúa solo local (los PDFs se generan igual)
|
||||
const registrarAlta = async () => {
|
||||
const creada = await crearAltaCliente(alta)
|
||||
if (creada) {
|
||||
await subirDocumentos(creada.id, alta)
|
||||
setRegistro(creada.id)
|
||||
const res = await crearAltaCliente(alta)
|
||||
if (res.ok) {
|
||||
await subirDocumentos(res.id, alta)
|
||||
setRegistro(res.id)
|
||||
setSinConexion(false)
|
||||
setErrorValidacion('')
|
||||
} else if (res.motivo === 'validacion') {
|
||||
setRegistro('')
|
||||
setSinConexion(false)
|
||||
setErrorValidacion(res.detalle ?? 'Datos incompletos o inválidos')
|
||||
} else {
|
||||
setRegistro('')
|
||||
setSinConexion(true)
|
||||
setErrorValidacion('')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,6 +141,14 @@ export default function AltaClientePage() {
|
||||
Sin conexión al servidor — el expediente se generó solo localmente
|
||||
</p>
|
||||
)}
|
||||
{errorValidacion && (
|
||||
<p
|
||||
role="alert"
|
||||
className="mb-8 border border-red-300 bg-red-50 px-4 py-3 text-xs font-bold uppercase tracking-widest text-red-700"
|
||||
>
|
||||
El servidor rechazó el alta: {errorValidacion}
|
||||
</p>
|
||||
)}
|
||||
<FirmasForm
|
||||
alta={alta}
|
||||
onCambiarFirma={(f) => actualizar('firma', f)}
|
||||
|
||||
Reference in New Issue
Block a user