From 2a939def1dd85d1b6e2227cc6b021614913e4c4d Mon Sep 17 00:00:00 2001 From: Rodrigo Bertoldo de Sousa Martins Date: Wed, 1 Apr 2026 15:44:32 -0300 Subject: [PATCH] =?UTF-8?q?TopSapp:=20Mudan=C3=A7as=20na=20exibi=C3=A7?= =?UTF-8?q?=C3=A3o=20de=20servi=C3=A7os=20no=20ver=20faturas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rodrigo Bertoldo de Sousa Martins --- src/bot/handler.js | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/bot/handler.js b/src/bot/handler.js index eafab75..dc41e66 100644 --- a/src/bot/handler.js +++ b/src/bot/handler.js @@ -4616,10 +4616,32 @@ Digite /help para ver todos os comandos disponíveis! let message = `📄 **SELECIONE O SERVIÇO**\n\n`; message += `🆔 **ID Cliente**: ${idCliente}\n`; message += `📊 Este cliente possui **${faturasPorServico.length} serviços** com faturas.\n\n`; + + faturasPorServico.forEach((servicoInfo, index) => { + const s = servicoInfo.servico; + const rawStatus = String(s.status || '').toLowerCase(); + let statusText; + if (rawStatus === 'liberado' || rawStatus === '1' || parseInt(s.status) === 1) { + statusText = '🟢 Liberado'; + } else if (rawStatus === 'bloqueado' || rawStatus === '2' || parseInt(s.status) === 2) { + statusText = '🔴 Bloqueado'; + } else if (rawStatus === 'desativado' || rawStatus === '3' || parseInt(s.status) === 3) { + statusText = '⚫ Desativado'; + } else { + statusText = `❓ ${s.status || 'Desconhecido'}`; + } + + message += `*${index + 1}. ${s.nome || 'Serviço'}*\n`; + if (s.login) message += ` 👤 Login PPPoE: \`${s.login}\`\n`; + message += ` 📊 Status: ${statusText}\n`; + if (s.endereco) message += ` 📍 Endereço: ${s.endereco}\n`; + message += ` 🧾 ${servicoInfo.faturas.length} fatura(s)\n\n`; + }); + message += `Escolha qual serviço deseja ver as faturas:`; - - const keyboard = faturasPorServico.map((servicoInfo) => [{ - text: `📋 ${servicoInfo.servico.nome || servicoInfo.servico.descricao || 'Serviço'} — ${servicoInfo.faturas.length} fatura(s)`, + + const keyboard = faturasPorServico.map((servicoInfo, index) => [{ + text: `${index + 1}. ${servicoInfo.servico.login || servicoInfo.servico.nome || 'Serviço'} — ${servicoInfo.faturas.length} fatura(s)`, callback_data: `faturas_servico_${idCliente}_${servicoInfo.servico.id}_${location}` }]);