From 5947a3eaa3172233d4693b5d58e6d4c336304b49 Mon Sep 17 00:00:00 2001 From: Gustavo Date: Mon, 3 Aug 2026 08:38:45 -0300 Subject: [PATCH] Add stage classification and appointment scheduling UI --- public/index.html | 2 +- public/js/campanhas.js | 32 ++++++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/public/index.html b/public/index.html index a14562a..dc3c01c 100644 --- a/public/index.html +++ b/public/index.html @@ -268,7 +268,7 @@ - +
Lead IDNumeroMensagemStatus
Lead IDNumeroMensagemStatusEstagio
diff --git a/public/js/campanhas.js b/public/js/campanhas.js index aa4e72b..775b6f8 100644 --- a/public/js/campanhas.js +++ b/public/js/campanhas.js @@ -135,17 +135,41 @@ const Campanhas = (() => { )); } + const STAGE_OPTIONS = [ + 'respondeu', 'interessado', 'demonstracao_agendada', 'sem_interesse', 'opt_out', 'venda_fechada' + ]; + async function carregarFila(campanhaId) { const status = el('fila-filtro-status').value; const { fila } = await API.get(`/api/campaigns/${campanhaId}/fila?status=${status}`); - el('fila-tabela').replaceChildren(...fila.map((linha) => - h('tr', {}, + el('fila-tabela').replaceChildren(...fila.map((linha) => { + const podeMarcarEstagio = linha.status === 'sent' || linha.status === 'error'; + const stageSelect = h('select', { class: 'fila-estagio-select', disabled: podeMarcarEstagio ? null : 'disabled' }, + h('option', { value: '' }, '—'), + ...STAGE_OPTIONS.map((s) => h('option', { value: s }, s))); + const marcarBtn = h('button', { + class: 'btn-ghost btn-sm', type: 'button', disabled: podeMarcarEstagio ? null : 'disabled', + onclick: async () => { + if (!stageSelect.value) return; + await API.post(`/api/campaigns/leads/${linha.lead_id}/estagio`, { stage: stageSelect.value, campaignId: campanhaId }); + toast('Estagio atualizado'); + if (stageSelect.value === 'demonstracao_agendada') { + const dataAgendamento = prompt('Data/hora do agendamento (AAAA-MM-DD HH:MM):'); + if (dataAgendamento) { + await API.post(`/api/campaigns/leads/${linha.lead_id}/agendamentos`, { kind: 'demonstracao', scheduledAt: dataAgendamento }); + toast('Agendamento registrado'); + } + } + } + }, 'Marcar'); + return h('tr', {}, h('td', {}, h('input', { type: 'checkbox', class: 'fila-check', value: linha.id })), h('td', {}, String(linha.lead_id)), h('td', {}, linha.numero), h('td', {}, linha.rendered_message), - h('td', {}, linha.status)) - )); + h('td', {}, linha.status), + h('td', { class: 'row' }, stageSelect, marcarBtn)); + })); } function filaSelecionada() {