Skip to content

Claude/mentorship crm system bb6 yg#147

Open
caimanoliveira wants to merge 14 commits intosupabase:mainfrom
caimanoliveira:claude/mentorship-crm-system-BB6YG
Open

Claude/mentorship crm system bb6 yg#147
caimanoliveira wants to merge 14 commits intosupabase:mainfrom
caimanoliveira:claude/mentorship-crm-system-BB6YG

Conversation

@caimanoliveira
Copy link

What kind of change does this PR introduce?

Bug fix, feature, docs update, ...

What is the current behavior?

Please link any relevant issues here.

What is the new behavior?

Feel free to include screenshots if it includes visual changes.

Additional context

Add any other context or screenshots.

claude added 14 commits March 20, 2026 02:43
Initial planning document for the mentorship CRM system including tech stack, database schema, page structure, and implementation phases.

https://claude.ai/code/session_0118ojZM3u7GeunLzKgKKvHa
Complete CRM system for mentorship lead management with:
- Kanban board with drag & drop (dnd-kit) across 6 pipeline stages
- Lead CRUD with contact info, proposal details, and source tracking
- Interaction timeline per lead (notes, stage changes, meetings)
- Meeting scheduler with date, time and video link
- Dashboard with KPI metrics (total leads, conversion rate, pipeline value)
- Settings page to manage stages, products, and lead sources
- WhatsApp notifications via CallMeBot API for meeting reminders
- Supabase (PostgreSQL) schema + seed with default stages and products
- Built with Next.js 16, Tailwind CSS v4, and custom UI components

https://claude.ai/code/session_0118ojZM3u7GeunLzKgKKvHa
Creates tables: stages, products, sources, leads, meetings, interactions
with indexes, FK constraints, and updated_at trigger.

https://claude.ai/code/session_0118ojZM3u7GeunLzKgKKvHa
Fix supabase#1 - useLeads.ts: remove busca de todas as reuniões no select
principal. Agora faz uma segunda query indexada (idx_meetings_lead_date)
buscando somente reuniões futuras dos leads retornados, eliminando
o filtro client-side que processava todos os registros em JS.

Fix supabase#2 - RPCs transacionais: cria migration com 4 funções Postgres
que executam lead+interaction e meeting+interaction em transação
única, eliminando race conditions onde o segundo insert podia falhar
sem rollback do primeiro.

- create_lead_with_interaction
- update_lead_with_interaction
- create_meeting_with_interaction
- move_lead_stage (kanban drag)

Adiciona índice composto meetings(lead_id, date) para suportar Fix supabase#1.

https://claude.ai/code/session_0118ojZM3u7GeunLzKgKKvHa
- handleDragEnd agora usa o estado local (leadsByStage) para determinar
  o estágio destino, evitando ambiguidade do over.id com closestCorners
- Substitui RPC move_lead_stage por chamadas diretas ao Supabase
  (update na tabela leads + insert na tabela interactions), eliminando
  dependência de função que pode não existir no banco

https://claude.ai/code/session_0118ojZM3u7GeunLzKgKKvHa
handleDragEnd lia o leadsByStage da closure do render anterior,
fazendo o card sempre aparecer na coluna original e disparando o
early return (stage_id === targetStageId) sem salvar no banco.

Solução: useRef atualizado de forma síncrona dentro do setState
em handleDragOver, garantindo que handleDragEnd sempre leia o
estado mais recente independente do ciclo de render do React.

https://claude.ai/code/session_0118ojZM3u7GeunLzKgKKvHa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants