Muestra fotos y notas por zona en la ficha del lead

- agruparPorZona (lib/funnel/fotos.ts): helper puro que agrupa fotos
  (antes/después) y notas por zona, con fallback al tipo del lead. 5 tests.
- getLead trae también lead_notas.
- LeadFotosGaleria: galería por zona (Antes/Después + notas) que sustituye el
  grid plano de la ficha del panel.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Carlos Narro
2026-06-03 19:22:12 +02:00
parent 0a5f8cba2b
commit 5df608f203
5 changed files with 186 additions and 12 deletions

View File

@@ -3,6 +3,7 @@ import { db } from './index';
import {
leads,
leadFotos,
leadNotas,
leadEstadoHistory,
leadPipelineEventos,
precisionHistory,
@@ -31,8 +32,9 @@ export async function getLead(id: string) {
if (!lead) return null;
const [fotos, eventos, historial, precision] = await Promise.all([
const [fotos, notas, eventos, historial, precision] = await Promise.all([
db.select().from(leadFotos).where(eq(leadFotos.leadId, id)).orderBy(asc(leadFotos.orden)),
db.select().from(leadNotas).where(eq(leadNotas.leadId, id)).orderBy(asc(leadNotas.createdAt)),
db
.select()
.from(leadPipelineEventos)
@@ -46,7 +48,7 @@ export async function getLead(id: string) {
db.select().from(precisionHistory).where(eq(precisionHistory.leadId, id)),
]);
return { lead, fotos, eventos, historial, precision: precision[0] ?? null };
return { lead, fotos, notas, eventos, historial, precision: precision[0] ?? null };
}
export async function getResumen() {