From f297aabc1a0a9423b2f1ff1c1219380ca5fb8c45 Mon Sep 17 00:00:00 2001 From: Consult AS Technology Date: Tue, 8 Sep 2026 06:00:24 +0000 Subject: [PATCH] =?UTF-8?q?fix(afluencia):=20dropdowns=20salarios=20+=20lo?= =?UTF-8?q?=20quiere=20para=20+=20redirect=20Mi=20d=C3=ADa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Rango salarial: input → select con 14 rangos (A-0 a M-100001) - Lo quiere para: input → select con 2 opciones (Vivir / Inversión) - Validación labels origen/desarrollo tolerante en backend (omitir si no existe) - Redirect a /hoy/ después de crear afluencia o completar alta cliente --- .../src/controllers/leads.controller.ts | 22 ++++++---- .../src/components/AltaAfluenciaForm.tsx | 43 ++++++++++++++++--- .../src/pages/AltaClientePage.tsx | 14 ++++++ 3 files changed, 64 insertions(+), 15 deletions(-) diff --git a/api-gateway/src/controllers/leads.controller.ts b/api-gateway/src/controllers/leads.controller.ts index 0a30904..f983621 100644 --- a/api-gateway/src/controllers/leads.controller.ts +++ b/api-gateway/src/controllers/leads.controller.ts @@ -291,17 +291,23 @@ export async function crearAfluencia( if (existente) return { duplicado: { id: existente.id, nombre: existente.nombre } } } - if (datos.origen !== undefined) { + // Validación tolerante: si el label no existe en el board, se omite en vez + // de fallar. Esto evita 400 cuando Monday aún no propagó un label nuevo. + let origenSafe = datos.origen + if (origenSafe !== undefined) { const labels = await monday.labelsDeColumna(boardOportunidades, 'Origen del Lead') - if (!labels.includes(datos.origen)) { - throw new AppError(400, `Origen inválido: "${datos.origen}". Labels válidos: ${labels.join(', ')}`) + if (!labels.includes(origenSafe)) { + console.warn(`Origen "${origenSafe}" no es label del board; se omite`) + origenSafe = undefined } } - if (datos.desarrollo !== undefined) { + let desarrolloSafe = datos.desarrollo + if (desarrolloSafe !== undefined) { const labels = await monday.labelsDeColumna(boardOportunidades, 'Desarrollo') - if (!labels.includes(datos.desarrollo)) { - throw new AppError(400, `Desarrollo inválido: "${datos.desarrollo}". Labels válidos: ${labels.join(', ')}`) + if (!labels.includes(desarrolloSafe)) { + console.warn(`Desarrollo "${desarrolloSafe}" no es label del board; se omite`) + desarrolloSafe = undefined } } @@ -309,8 +315,8 @@ export async function crearAfluencia( nombre: datos.nombre, telefono: datos.telefono, email: datos.email, - desarrolloLabel: datos.desarrollo, - origenLabel: datos.origen, + desarrolloLabel: desarrolloSafe, + origenLabel: origenSafe, modeloLabel: datos.modelo, medioContacto: datos.medioContacto, edad: datos.edad, diff --git a/apps/alta-clientes/src/components/AltaAfluenciaForm.tsx b/apps/alta-clientes/src/components/AltaAfluenciaForm.tsx index 121c521..8f93cc8 100644 --- a/apps/alta-clientes/src/components/AltaAfluenciaForm.tsx +++ b/apps/alta-clientes/src/components/AltaAfluenciaForm.tsx @@ -1,4 +1,4 @@ -import { useState, type FormEvent } from 'react' +import { useEffect, useState, type FormEvent } from 'react' import { z } from 'zod' import { crearAfluencia, type LeadResumen } from '../services/api' import BusquedaLead from './BusquedaLead' @@ -189,6 +189,15 @@ export default function AltaAfluenciaForm({ onVolver, onPasarAAltaCliente, valor setAsignacion(null) } + // Redirigir a Mi día 2 s después de registrar la afluencia + useEffect(() => { + if (leadCreado === null) return + const timer = setTimeout(() => { + window.location.href = '/hoy/' + }, 2000) + return () => clearTimeout(timer) + }, [leadCreado]) + if (leadCreado !== null) { return (
@@ -202,6 +211,9 @@ export default function AltaAfluenciaForm({ onVolver, onPasarAAltaCliente, valor ? 'Registrado en afluencia — asignado a ti' : 'Registrado en afluencia — se asignará por round-robin'}

+

+ Redirigiendo a Mi día en unos segundos… +