feat: implementada funcionalidade de exclusao de leads via API e botoes na interface (Kanban, Tabela Analitica e Modal)

This commit is contained in:
2026-08-26 18:29:11 -03:00
parent 1513c65056
commit 1bfb89626f
5 changed files with 53 additions and 11 deletions
+14 -4
View File
@@ -88,19 +88,29 @@ def render_analytical_table_view(api_client: APIClient):
)
st.markdown("### ⚙️ Ações Rápidas")
col_sel, col_act = st.columns([2, 1])
col_sel, col_opt, col_del = st.columns([2, 1, 1])
with col_sel:
selected_lead_id = st.selectbox(
"Selecione um Lead para Ação LGPD:",
"Selecione um Lead para Ação:",
options=[l['id'] for l in filtered],
format_func=lambda x: next((f"{l['nome_empresa']} ({l['status_funil']})" for l in filtered if l['id'] == x), x)
)
with col_act:
if st.button("🚫 Marcar Opt-Out (LGPD)", type="secondary", use_container_width=True):
with col_opt:
if st.button("🚫 Opt-Out (LGPD)", type="secondary", use_container_width=True):
if selected_lead_id:
api_client.opt_out_lead(selected_lead_id)
st.success("Lead marcado como Opt-Out (Excluído / LGPD).")
st.rerun()
with col_del:
if st.button("🗑️ Deletar do Banco", type="primary", use_container_width=True):
if selected_lead_id:
ok, msg = api_client.delete_lead(selected_lead_id)
if ok:
st.success(msg)
else:
st.error(msg)
st.rerun()
else:
st.info("Nenhum lead encontrado com os filtros selecionados.")
+14 -4
View File
@@ -65,22 +65,32 @@ def render_lead_detail_modal(lead_id: str, api_client: APIClient):
new_notes = st.text_area("Notas / Observações Comerciais:", value=lead_detail.get('notas', ''), height=120)
c_save, c_opt, c_close = st.columns([1, 1, 1])
c_save, c_opt, c_del, c_close = st.columns([1, 1, 1, 1])
with c_save:
if st.button("💾 Salvar Notas"):
if st.button("💾 Salvar Notas", use_container_width=True):
api_client.update_lead(lead_id, {'notas': new_notes})
st.success("Notas atualizadas!")
st.rerun()
with c_opt:
if st.button("🚫 Opt-Out (LGPD)", help="Marcar lead para não contatar"):
if st.button("🚫 Opt-Out (LGPD)", help="Marcar lead para não contatar", use_container_width=True):
api_client.opt_out_lead(lead_id)
st.warning("Lead marcado como Opt-Out LGPD.")
st.session_state.pop('selected_lead_id', None)
st.rerun()
with c_del:
if st.button("🗑️ Deletar Lead", type="primary", help="Excluir lead permanentemente do banco", use_container_width=True):
ok, msg = api_client.delete_lead(lead_id)
if ok:
st.success(msg)
else:
st.error(msg)
st.session_state.pop('selected_lead_id', None)
st.rerun()
with c_close:
if st.button("❌ Fechar"):
if st.button("❌ Fechar", use_container_width=True):
st.session_state.pop('selected_lead_id', None)
st.rerun()