fix(notas): notas persisten entre etapas via clienteClave
- Campo clienteClave en RecordatorioVendedor (hash nombre+telefono) - Al crear nota: se calcula clienteClave del lead/cliente - Al buscar notas: busca por leadId O clienteClave (no por nombre suelto) - Mantiene compatibilidad: notas viejas sin clienteClave siguen por leadId - Migración SQL aplicada
This commit is contained in:
@@ -9,6 +9,7 @@ const crearSchema = z.object({
|
||||
titulo: z.string().min(1),
|
||||
descripcion: z.string().optional(),
|
||||
leadId: z.string().optional(),
|
||||
clienteClave: z.string().optional(),
|
||||
fechaRecordar: z.string().min(1),
|
||||
})
|
||||
|
||||
@@ -24,6 +25,7 @@ export async function crearRecordatorioEndpoint(req: Request, res: Response): Pr
|
||||
titulo: body.titulo,
|
||||
descripcion: body.descripcion ?? null,
|
||||
leadId: body.leadId ?? null,
|
||||
clienteClave: body.clienteClave ?? null,
|
||||
fechaRecordar: body.fechaRecordar,
|
||||
})
|
||||
res.status(201).json(recordatorio)
|
||||
@@ -38,9 +40,10 @@ export async function listarRecordatoriosEndpoint(req: Request, res: Response):
|
||||
if (!usuarioId) throw new Error('Auth requerida')
|
||||
|
||||
const completadosStr = req.query['completados'] as string | undefined
|
||||
const opts: { completados?: boolean; desde?: string | null; hasta?: string | null } = {
|
||||
const opts: { completados?: boolean; desde?: string | null; hasta?: string | null; clienteClave?: string | null } = {
|
||||
desde: (req.query['desde'] as string) ?? null,
|
||||
hasta: (req.query['hasta'] as string) ?? null,
|
||||
clienteClave: (req.query['clienteClave'] as string) ?? null,
|
||||
}
|
||||
if (completadosStr === 'true') opts.completados = true
|
||||
else if (completadosStr === 'false') opts.completados = false
|
||||
@@ -78,6 +81,7 @@ export function crearController(svc: RecordatorioVendedorService) {
|
||||
titulo: body.titulo,
|
||||
descripcion: body.descripcion ?? null,
|
||||
leadId: body.leadId ?? null,
|
||||
clienteClave: body.clienteClave ?? null,
|
||||
fechaRecordar: body.fechaRecordar,
|
||||
})
|
||||
res.status(201).json(r)
|
||||
@@ -92,6 +96,7 @@ export function crearController(svc: RecordatorioVendedorService) {
|
||||
}
|
||||
if (completadosStr === 'true') opts.completados = true
|
||||
else if (completadosStr === 'false') opts.completados = false
|
||||
opts.clienteClave = (req.query['clienteClave'] as string) ?? null
|
||||
const items = await svc.listar(usuarioId, opts)
|
||||
res.json(items)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user