Add stage classification and appointment scheduling UI

This commit is contained in:
Gustavo
2026-08-03 08:38:45 -03:00
parent b4290452b3
commit 5947a3eaa3
2 changed files with 29 additions and 5 deletions
+1 -1
View File
@@ -268,7 +268,7 @@
<button class="btn-ghost btn-sm" id="btn-cancelar-selecionados" type="button">Cancelar selecionados</button>
</div>
<table>
<thead><tr><th></th><th>Lead ID</th><th>Numero</th><th>Mensagem</th><th>Status</th></tr></thead>
<thead><tr><th></th><th>Lead ID</th><th>Numero</th><th>Mensagem</th><th>Status</th><th>Estagio</th></tr></thead>
<tbody id="fila-tabela"></tbody>
</table>
</div>
+28 -4
View File
@@ -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() {