fix(afluencia): validación duplicados + campos nombre + fix lada
- Lead creation: validación por email y teléfono normalizados (últimos 10 dígitos) - Si ya existe lead con mismo email/teléfono → 409 con aviso - Alta Afluencia: nombre dividido en Nombre(s), Apellido Paterno, Apellido Materno - Fix lada: strip robusto de +52 y +1 con/sin espacio - Backend + frontend actualizados
This commit is contained in:
@@ -212,6 +212,18 @@ export async function crearLead(
|
||||
const existente = await monday.buscarLeadPorTelefono(datos.telefono)
|
||||
if (existente) return { duplicado: { id: existente.id, nombre: existente.nombre } }
|
||||
}
|
||||
// Dedup por email en ambos tableros
|
||||
if (datos.email !== undefined && datos.email.trim() !== '') {
|
||||
const [leads, oportunidades] = await Promise.all([
|
||||
monday.getLeads(),
|
||||
monday.getOportunidades(),
|
||||
])
|
||||
const emailLower = datos.email.trim().toLowerCase()
|
||||
const existenteLead = leads.find((l) => l.email?.toLowerCase() === emailLower)
|
||||
if (existenteLead) return { duplicado: { id: existenteLead.id, nombre: existenteLead.nombre } }
|
||||
const existenteOp = oportunidades.find((o) => o.email?.toLowerCase() === emailLower)
|
||||
if (existenteOp) return { duplicado: { id: existenteOp.id, nombre: existenteOp.nombre } }
|
||||
}
|
||||
|
||||
if (datos.origen !== undefined) {
|
||||
const labels = await monday.labelsDeColumna(boardLeads, 'Origen')
|
||||
|
||||
Reference in New Issue
Block a user