refactor: remove the WhatsApp integration
All checks were successful
Build and deploy / Validate source (push) Successful in 15s
Build and deploy / Integration suite on a real stack (push) Successful in 4m24s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m11s
All checks were successful
Build and deploy / Validate source (push) Successful in 15s
Build and deploy / Integration suite on a real stack (push) Successful in 4m24s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m11s
The system will not send WhatsApp messages: the client's n8n already does, from Tiny's status changes. Paid orders and stage changes now queue only the Tiny delivery; the fake WhatsApp adapter, its setting and secret, the Integrações row and the send log's Destino column are gone, and the old WhatsApp log rows are removed. The customer's WhatsApp number, the "Avisar no WhatsApp" link for corrections and the contact links stay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -42,7 +42,6 @@ TINY_ADAPTER=fake
|
||||
# JADLOG_CNPJ=... # the "Usuário" Jadlog issued, the CNPJ that contracts freight
|
||||
# JADLOG_CONTA=... # conta corrente
|
||||
# JADLOG_CONTRATO= # only if Jadlog issued a contract number
|
||||
WHATSAPP_ADAPTER=fake
|
||||
# E-mail stays in the database and the worker log (MAIL_ADAPTER=log). To send
|
||||
# through a real server: MAIL_ADAPTER=smtp with the settings below.
|
||||
# MAIL_FROM=DTF Dropstar <nao-responda@exemplo.com.br>
|
||||
|
||||
@@ -12,13 +12,10 @@ from botocore.exceptions import ClientError
|
||||
def require_runtime():
|
||||
"""Validate the supported local and R2-backed deployment modes.
|
||||
|
||||
Real payment, freight, ERP, and WhatsApp providers are deliberately not
|
||||
enabled yet. A non-local deployment keeps those adapters fake and disables
|
||||
checkout until their audited implementations are added.
|
||||
Each provider is fake until its settings are complete; a real one refuses
|
||||
to start without them.
|
||||
"""
|
||||
environment = os.environ.get('APP_ENV', 'local')
|
||||
if os.environ.get('WHATSAPP_ADAPTER') != 'fake':
|
||||
raise RuntimeError('WHATSAPP must use the currently supported fake adapter')
|
||||
freight = os.environ.get('FREIGHT_ADAPTER')
|
||||
if freight == 'jadlog':
|
||||
from .jadlog import required_settings as jadlog_settings
|
||||
@@ -197,11 +194,6 @@ class FakeTiny:
|
||||
return {'provider': 'fake-tiny', 'reference': f"LOCAL-{payload['number']}",
|
||||
'event_key': event_key, 'status': 'recorded-locally'}
|
||||
|
||||
class FakeWhatsApp:
|
||||
def deliver(self, event_key: str, payload: dict) -> dict:
|
||||
return {'provider': 'fake-whatsapp', 'event_key': event_key,
|
||||
'event': payload['event'], 'status': 'recorded-locally'}
|
||||
|
||||
class ObjectStorage(Protocol):
|
||||
def begin(self, key: str) -> str: ...
|
||||
def parts(self, key: str, upload_id: str) -> list: ...
|
||||
|
||||
@@ -267,7 +267,7 @@ def payment_events(state: Literal['open','resolved','all'] = 'open',
|
||||
|
||||
|
||||
@router.get('/api/operator/events')
|
||||
def events(provider: Literal['tiny','whatsapp'] | None = None,
|
||||
def events(provider: Literal['tiny'] | None = None,
|
||||
status: Literal['delivered','queued','failing'] | None = None,
|
||||
event: Literal['payment_approved','production_started','correction_needed','ready'] | None = None,
|
||||
order: int | None = Query(default=None, ge=1), offset: int = Query(default=0, ge=0),
|
||||
@@ -631,9 +631,8 @@ def move(uid: UUID, body: Move, user=Depends(can('produce'))):
|
||||
sale = c.execute("SELECT receipt FROM dtf_local.outbox WHERE event_key=%s AND delivered_at IS NOT NULL",
|
||||
(f'{uid}:paid:tiny',)).fetchone()
|
||||
tiny = {**event, 'order': row['snapshot'], 'tiny_id': ((sale or {}).get('receipt') or {}).get('tiny_id')}
|
||||
for provider, payload in (('tiny', tiny), ('whatsapp', event)):
|
||||
key = f'{uid}:{events[body.state]}:{provider}' if once else f'{uid}:{changed["version"]}:{provider}'
|
||||
enqueue(c, key, provider, payload)
|
||||
key = f'{uid}:{events[body.state]}:tiny' if once else f'{uid}:{changed["version"]}:tiny'
|
||||
enqueue(c, key, 'tiny', tiny)
|
||||
return changed
|
||||
|
||||
@router.post('/api/operator/orders/{uid}/print-files')
|
||||
|
||||
@@ -27,7 +27,6 @@ SECRET_FILE_SETTINGS = (
|
||||
'PAYMENT_TOKEN',
|
||||
'PAYMENT_WEBHOOK_SECRET',
|
||||
'TINY_TOKEN',
|
||||
'WHATSAPP_TOKEN',
|
||||
'SMTP_PASSWORD',
|
||||
'CORREIOS_CODIGO_ACESSO',
|
||||
)
|
||||
|
||||
@@ -99,10 +99,9 @@ def create_order(c, quote, payment):
|
||||
queue_print_files(c, order['id'], len(approved['items']))
|
||||
if is_test(order):
|
||||
return order, True
|
||||
for provider in ('tiny', 'whatsapp'):
|
||||
enqueue(c, f"{order['id']}:paid:{provider}", provider,
|
||||
{'order_id': str(order['id']), 'number': order['number'],
|
||||
'event': 'payment_approved', 'order': approved})
|
||||
enqueue(c, f"{order['id']}:paid:tiny", 'tiny',
|
||||
{'order_id': str(order['id']), 'number': order['number'],
|
||||
'event': 'payment_approved', 'order': approved})
|
||||
mail.alert(c, f"Pedido #{order['number']} pago · {mail.money(approved['total_cents'])}",
|
||||
['Um pedido novo foi pago e está em Arte recebida.', '', *mail.summary(approved)], '/')
|
||||
return order, True
|
||||
|
||||
@@ -173,6 +173,9 @@ CREATE INDEX IF NOT EXISTS order_files_upload ON dtf_local.order_files(upload_id
|
||||
-- index stays the size of the backlog rather than of all history.
|
||||
CREATE INDEX IF NOT EXISTS outbox_pending ON dtf_local.outbox(available_at, id)
|
||||
WHERE delivered_at IS NULL;
|
||||
-- The system sends no WhatsApp messages (the client's own n8n does, from Tiny):
|
||||
-- its old log rows would wait for an adapter that no longer exists.
|
||||
DELETE FROM dtf_local.outbox WHERE provider='whatsapp';
|
||||
|
||||
-- The scanner and the retention sweep both walk live uploads in arrival order.
|
||||
-- now() cannot appear in a partial index predicate, so the time comparisons stay
|
||||
|
||||
@@ -7,7 +7,7 @@ import time
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
from psycopg.types.json import Jsonb
|
||||
from . import mail
|
||||
from .adapters import FakeTiny, FakeWhatsApp, LocalS3Storage, require_runtime
|
||||
from .adapters import FakeTiny, LocalS3Storage, require_runtime
|
||||
from .core.secrets import load as load_secret_files
|
||||
from .core.db import connect
|
||||
from .printjobs import render_loop
|
||||
@@ -15,7 +15,7 @@ from .scanning import ClamAV, scan_loop
|
||||
|
||||
load_secret_files()
|
||||
require_runtime()
|
||||
adapters = {'tiny': FakeTiny(), 'whatsapp': FakeWhatsApp()}
|
||||
adapters = {'tiny': FakeTiny()}
|
||||
# Not yet confirmed against the client's account; see app/tiny.py.
|
||||
if os.environ.get('TINY_ADAPTER') == 'tiny':
|
||||
from .tiny import TinyOrders
|
||||
|
||||
@@ -79,7 +79,6 @@ x-app: &app
|
||||
TINY_SKU_METRO_UV_FOLHA: ${TINY_SKU_METRO_UV_FOLHA:-}
|
||||
TINY_SKU_METRO_UV_AVULSA: ${TINY_SKU_METRO_UV_AVULSA:-}
|
||||
TINY_ECOMMERCE_ID: ${TINY_ECOMMERCE_ID:-}
|
||||
WHATSAPP_ADAPTER: fake
|
||||
# log keeps each e-mail in the database and the worker's log, with the
|
||||
# recovery link readable there; smtp with the SMTP_* settings in .env.
|
||||
MAIL_ADAPTER: ${MAIL_ADAPTER:-log}
|
||||
|
||||
@@ -6,7 +6,7 @@ substitute for `production_preflight.py`, CI, staging acceptance, or change appr
|
||||
## Application and external contracts
|
||||
|
||||
- [ ] `docs/PRODUCTION_INPUTS.md` has owners, decisions, and evidence for every item.
|
||||
- [ ] Production R2, freight, Mercado Pago, Tiny/Olist, and WhatsApp adapters have
|
||||
- [ ] Production R2, freight, Mercado Pago, and Tiny/Olist adapters have
|
||||
sandbox contract tests and least-privilege credentials.
|
||||
- [ ] Payment webhook authenticity, replay handling, and idempotency are tested.
|
||||
- [ ] Docker secret `*_FILE` loading is implemented and tested without logging values.
|
||||
|
||||
@@ -44,7 +44,6 @@ TINY_PRODUCT_UV_AVULSA=TBD
|
||||
TINY_FORMA_ENVIO_RETIRADA=TBD
|
||||
# true only at go-live, after the n8n DTFIMP designer branch is removed.
|
||||
TINY_STATUS_UPDATES=false
|
||||
WHATSAPP_ADAPTER=TBD
|
||||
# E-mail (password recovery and team alerts). off until the SMTP account exists.
|
||||
MAIL_ADAPTER=off
|
||||
MAIL_FROM=DTF Dropstar <nao-responda@SITE_DOMAIN>
|
||||
@@ -79,4 +78,3 @@ OPERATOR_PASSWORD_SECRET=TBD
|
||||
PAYMENT_TOKEN_SECRET=TBD
|
||||
PAYMENT_WEBHOOK_SECRET=TBD
|
||||
TINY_TOKEN_SECRET=TBD
|
||||
WHATSAPP_TOKEN_SECRET=TBD
|
||||
|
||||
@@ -20,12 +20,12 @@ REQUIRED = (
|
||||
'POSTGRES_DB', 'POSTGRES_USER', 'APP_DB_USER', 'POSTGRES_VOLUME', 'OPERATOR_EMAIL',
|
||||
'STORAGE_QUOTA_BYTES', 'OWNER_UPLOAD_QUOTA_BYTES', 'MAX_UPLOAD_BYTES',
|
||||
'UPLOAD_PART_BYTES', 'MAX_PENDING_UPLOADS', 'SCAN_MAX_BYTES',
|
||||
'PAYMENT_ADAPTER', 'FREIGHT_ADAPTER', 'TINY_ADAPTER', 'WHATSAPP_ADAPTER',
|
||||
'PAYMENT_ADAPTER', 'FREIGHT_ADAPTER', 'TINY_ADAPTER',
|
||||
'DATABASE_URL_SECRET', 'DATABASE_ADMIN_URL_SECRET',
|
||||
'DB_ADMIN_PASSWORD_SECRET', 'APP_DB_PASSWORD_SECRET',
|
||||
'R2_ACCESS_KEY_ID_SECRET', 'R2_SECRET_ACCESS_KEY_SECRET',
|
||||
'OPERATOR_PASSWORD_SECRET', 'PAYMENT_TOKEN_SECRET',
|
||||
'PAYMENT_WEBHOOK_SECRET', 'TINY_TOKEN_SECRET', 'WHATSAPP_TOKEN_SECRET',
|
||||
'PAYMENT_WEBHOOK_SECRET', 'TINY_TOKEN_SECRET',
|
||||
)
|
||||
IMMUTABLE_IMAGE = re.compile(r'^[a-z0-9][a-z0-9._:/-]*@sha256:([0-9a-f]{64})$')
|
||||
IMAGE_REPOSITORY = re.compile(
|
||||
@@ -42,7 +42,7 @@ SOURCE_BLOCKERS = {
|
||||
'payment = FakePayment()',
|
||||
),
|
||||
'app/worker.py': (
|
||||
"adapters = {'tiny': FakeTiny(), 'whatsapp': FakeWhatsApp()}",
|
||||
"adapters = {'tiny': FakeTiny()}",
|
||||
),
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ def config_errors(values):
|
||||
bucket = values.get('R2_BUCKET', '')
|
||||
if bucket and not re.fullmatch(r'[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]', bucket):
|
||||
errors.append('R2_BUCKET must be a valid S3 bucket name')
|
||||
for name in ('PAYMENT_ADAPTER', 'FREIGHT_ADAPTER', 'TINY_ADAPTER', 'WHATSAPP_ADAPTER'):
|
||||
for name in ('PAYMENT_ADAPTER', 'FREIGHT_ADAPTER', 'TINY_ADAPTER'):
|
||||
if values.get(name, '').lower() in {'', 'fake', 'mock', 'local'}:
|
||||
errors.append(f'{name} must select an approved non-fake implementation')
|
||||
for name in REQUIRED:
|
||||
|
||||
@@ -59,14 +59,13 @@ def valid_config():
|
||||
'PAYMENT_ADAPTER': 'mercado-pago',
|
||||
'FREIGHT_ADAPTER': 'approved-freight',
|
||||
'TINY_ADAPTER': 'tiny-olist',
|
||||
'WHATSAPP_ADAPTER': 'approved-whatsapp',
|
||||
}
|
||||
for name in (
|
||||
'DATABASE_URL_SECRET', 'DATABASE_ADMIN_URL_SECRET',
|
||||
'DB_ADMIN_PASSWORD_SECRET', 'APP_DB_PASSWORD_SECRET',
|
||||
'R2_ACCESS_KEY_ID_SECRET', 'R2_SECRET_ACCESS_KEY_SECRET',
|
||||
'OPERATOR_PASSWORD_SECRET', 'PAYMENT_TOKEN_SECRET',
|
||||
'PAYMENT_WEBHOOK_SECRET', 'TINY_TOKEN_SECRET', 'WHATSAPP_TOKEN_SECRET',
|
||||
'PAYMENT_WEBHOOK_SECRET', 'TINY_TOKEN_SECRET',
|
||||
):
|
||||
values[name] = 'dtf_prod_' + name.lower()
|
||||
return values
|
||||
|
||||
@@ -111,7 +111,6 @@ x-app-environment: &app-environment
|
||||
# only together with TINY_ADAPTER=tiny and after n8n stops sending the
|
||||
# designer message for DTFIMP products.
|
||||
TINY_STATUS_UPDATES: ${TINY_STATUS_UPDATES:-false}
|
||||
WHATSAPP_ADAPTER: fake
|
||||
# E-mail: customers' password recovery and the team's alerts (app/mail.py).
|
||||
# off until the client's SMTP account exists; then smtp with the settings
|
||||
# below, or the API and worker refuse to start. SMTP_SECURITY is starttls
|
||||
|
||||
@@ -38,7 +38,9 @@ online system, not factory-machine automation.
|
||||
- Freight quotation and charging at checkout.
|
||||
- Idempotent Tiny/Olist order integration and order traceability.
|
||||
- Online Kanban for production status and secure file download.
|
||||
- WhatsApp status notifications.
|
||||
- Customer status notices: not sent by this system. The client's own n8n sends
|
||||
WhatsApp messages from Tiny's status changes (decided 2026-10-16); the Kanban
|
||||
only offers a one-click WhatsApp link for a correction.
|
||||
- Private object storage, 30-day file retention, backups, and basic security.
|
||||
- Operator guidance for the factory team.
|
||||
|
||||
@@ -316,7 +318,7 @@ as references and are not imported or started by Compose.
|
||||
jobs provision restricted runtime identities, for nine Compose services total.
|
||||
- MinIO implements the S3 storage boundary with direct multipart browser uploads,
|
||||
resumable parts, private objects, and short-lived signed operator downloads.
|
||||
- Payment, freight, Tiny/Olist, and WhatsApp use fake adapters only. No production
|
||||
- Payment, freight, and Tiny/Olist use fake adapters only. No production
|
||||
credentials or integrations are configured. The API and worker have no external
|
||||
network route; only local web/storage gateways publish loopback ports.
|
||||
- The original Site commercial calculation and appearance remain the source of
|
||||
|
||||
@@ -134,9 +134,8 @@ def run():
|
||||
events = board.call('/operator/events?order=' + str(order['number']), operator=True)['events']
|
||||
paid = [e for e in events if e['payload'].get('order_id') == order['id']
|
||||
and e['payload'].get('event') == 'payment_approved']
|
||||
assert len(paid) == 2, f'expected one tiny and one whatsapp event, got {len(paid)}'
|
||||
assert {e['provider'] for e in paid} == {'tiny', 'whatsapp'}, paid
|
||||
print('PASS: exactly one notification per provider for the order')
|
||||
assert [e['provider'] for e in paid] == ['tiny'], paid
|
||||
print('PASS: exactly one Tiny notification for the order')
|
||||
|
||||
# A payment that was never reviewed, and one for something that is not a quote.
|
||||
deliver({'event_id': 'nonsense-' + uuid4().hex, 'reference': 'not-a-uuid',
|
||||
@@ -160,7 +159,7 @@ def run():
|
||||
queued = c.execute("SELECT count(*) AS n FROM dtf_local.outbox WHERE event_key LIKE %s", (order['id'] + ':%',)).fetchone()['n']
|
||||
jobs = c.execute('SELECT count(*) AS n FROM dtf_local.print_files WHERE order_id=%s', (order['id'],)).fetchone()['n']
|
||||
assert queued == 0 and jobs == 1, (queued, jobs)
|
||||
print('PASS: an operator test order reaches the board and the print queue, never Tiny or WhatsApp')
|
||||
print('PASS: an operator test order reaches the board and the print queue, never Tiny')
|
||||
|
||||
# Files are uploaded before payment. An unpaid cart keeps them briefly; a
|
||||
# paid order keeps them for its 30 days; a payment never starts for files
|
||||
|
||||
@@ -240,7 +240,7 @@ def run():
|
||||
assert len(client.call('/operator/orders/'+oid+'/history',operator=True))==6
|
||||
# A mistaken move can be undone one stage at a time, with an internal
|
||||
# reason. The customer is not told again: going back and forward once more
|
||||
# adds no messages (the outbox count below stays 8).
|
||||
# adds no messages (the outbox count below stays 4).
|
||||
client.call('/operator/orders/'+oid+'/move',{'state':'imp','version':version},operator=True,expected=422)
|
||||
client.call('/operator/orders/'+oid+'/move',{'state':'tra','version':version},operator=True,expected=409)
|
||||
back=client.call('/operator/orders/'+oid+'/move',{'state':'imp','version':version,'reason':'Movido por engano'},operator=True)
|
||||
@@ -258,16 +258,15 @@ def run():
|
||||
deadline=time.monotonic()+30
|
||||
while time.monotonic()<deadline:
|
||||
events=[e for e in client.call('/operator/events?order='+str(order['number']),operator=True)['events'] if e['payload']['order_id']==oid]
|
||||
if len(events)==8 and all(e['delivered_at'] and e['receipt'] for e in events):break
|
||||
if len(events)==4 and all(e['delivered_at'] and e['receipt'] for e in events):break
|
||||
time.sleep(1)
|
||||
else:raise AssertionError('Mock outbox did not drain')
|
||||
assert len({e['event_key'] for e in events})==8
|
||||
assert len({e['event_key'] for e in events})==4 and {e['provider'] for e in events}=={'tiny'}
|
||||
# Tiny sets the pickup situação from the order it is sent; the fake sale
|
||||
# has no Tiny id, so the real adapter would search for it.
|
||||
ready={e['provider']:e['payload'] for e in events if e['payload']['event']=='ready'}
|
||||
assert ready['tiny']['order']['freight']==order['snapshot']['freight'] and 'tiny_id' in ready['tiny']
|
||||
assert 'order' not in ready['whatsapp']
|
||||
print(f"PASS: 8 durable fake receipts. Local test order #{order['number']} retained in Finalizado.")
|
||||
print(f"PASS: 4 durable fake receipts. Local test order #{order['number']} retained in Finalizado.")
|
||||
return oid
|
||||
|
||||
if __name__=='__main__':run()
|
||||
|
||||
@@ -98,9 +98,9 @@
|
||||
<section id="tab-integrations" class="page" hidden>
|
||||
<h1>Integrações</h1>
|
||||
<section><div class="integ-list" id="integrations"></div></section>
|
||||
<section id="event-log"><h2>Registro de envios</h2>
|
||||
<section id="event-log"><h2>Envios ao Tiny</h2>
|
||||
<div class="filters" id="event-filters"></div>
|
||||
<table class="log"><thead><tr><th scope="col">Quando</th><th scope="col">Pedido</th><th scope="col">Destino</th><th scope="col">Evento</th><th scope="col">Resultado</th></tr></thead><tbody id="events"></tbody></table>
|
||||
<table class="log"><thead><tr><th scope="col">Quando</th><th scope="col">Pedido</th><th scope="col">Evento</th><th scope="col">Resultado</th></tr></thead><tbody id="events"></tbody></table>
|
||||
<div id="events-more"></div>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
@@ -622,7 +622,7 @@ function renderBoard(){
|
||||
return column;
|
||||
}));
|
||||
}
|
||||
// An operator's test order: no payment, no Tiny, no WhatsApp.
|
||||
// An operator's test order: no payment, no Tiny.
|
||||
const isTest=order=>order.payment?.provider==='teste';
|
||||
function card(order){
|
||||
const c=node('button',undefined,'card');c.type='button';c.dataset.card=order.id;c.draggable=!order.cancelled_at&&may('produce');
|
||||
@@ -726,7 +726,7 @@ function renderPanel(order){
|
||||
const stage=node('span',board.states[order.state],'stage');stage.style.setProperty('--c',color);
|
||||
const close=node('button',undefined,'close');close.type='button';close.setAttribute('aria-label','Fechar');close.append(icon(['M6 6l12 12M18 6L6 18']));close.onclick=closePanel;
|
||||
const test=isTest(order)?node('span','TESTE','tag-teste'):null;
|
||||
if(test)test.title='Pedido de teste: sem pagamento, não vai ao Tiny nem ao WhatsApp';
|
||||
if(test)test.title='Pedido de teste: sem pagamento, não vai ao Tiny';
|
||||
const code=node('span',undefined,'ocode');code.append('Pedido '+orderCode(order.id),copyButton(orderCode(order.id),'Copiar código do pedido'));
|
||||
code.title='O código que o cliente vê';
|
||||
row.append(node('span','#'+order.number,'num'),stage,...(test?[test]:[]),code,close);
|
||||
@@ -1373,7 +1373,7 @@ function review(quote){
|
||||
foot.append(discardButton(quote));
|
||||
// Tries the whole production flow without a payment.
|
||||
foot.append(button('Criar pedido de teste',async()=>{
|
||||
if(!window.confirm('Criar um pedido de TESTE para esta cotação? Não cobra nada e não vai para o Tiny nem para o WhatsApp.'))return;
|
||||
if(!window.confirm('Criar um pedido de TESTE para esta cotação? Não cobra nada e não vai para o Tiny.'))return;
|
||||
const order=await api('/quotes/'+quote.id+'/test-order',{});
|
||||
say('Pedido de teste #'+order.number+' criado em Arte recebida.');await load();
|
||||
},'btn ghost'));
|
||||
@@ -1571,7 +1571,7 @@ function renderIssues(){
|
||||
}
|
||||
|
||||
// The integration send log: filtered and paged on the server.
|
||||
let eventFilter={provider:'',status:'',event:'',order:''}, eventRows=[], eventTotal=0, eventPage=1, eventSize=20, eventLoading=0, eventTimer=null;
|
||||
let eventFilter={status:'',event:'',order:''}, eventRows=[], eventTotal=0, eventPage=1, eventSize=20, eventLoading=0, eventTimer=null;
|
||||
async function loadEvents(){
|
||||
const token=++eventLoading;
|
||||
const params=new URLSearchParams({limit:String(eventSize),offset:String((eventPage-1)*eventSize)});
|
||||
@@ -1595,7 +1595,6 @@ function eventFilters(){
|
||||
input.oninput=()=>{clearTimeout(eventTimer);eventTimer=setTimeout(()=>{eventFilter.order=input.value.trim();eventPage=1;loadEvents().catch(e=>say(e.message,true));},350);};
|
||||
order.append(input);
|
||||
bar.append(
|
||||
select('Destino','provider',[['','Todos'],['tiny','Tiny'],['whatsapp','WhatsApp']]),
|
||||
select('Situação','status',[['','Todas'],['delivered','Enviados'],['queued','Na fila'],['failing','Com erro']]),
|
||||
select('Evento','event',[['','Todos'],...Object.entries(EVENTS)]),
|
||||
order);
|
||||
@@ -1618,11 +1617,10 @@ function renderEvents(){
|
||||
const rows=eventRows.map(e=>{
|
||||
const tr=node('tr');const [result,cls]=eventResult(e);
|
||||
tr.append(node('td',when(e.delivered_at||e.available_at),'muted'),node('td','#'+e.payload.number,'mono'),
|
||||
node('td',{tiny:'Tiny',whatsapp:'WhatsApp'}[e.provider]||e.provider),
|
||||
node('td',EVENTS[e.payload.event]||e.payload.event),node('td',result,cls));
|
||||
return tr;
|
||||
});
|
||||
if(!rows.length){const tr=node('tr');const td=node('td','Nenhum envio encontrado.','faint');td.colSpan=5;tr.append(td);rows.push(tr);}
|
||||
if(!rows.length){const tr=node('tr');const td=node('td','Nenhum envio encontrado.','faint');td.colSpan=4;tr.append(td);rows.push(tr);}
|
||||
$('events').replaceChildren(...rows);
|
||||
$('events-more').replaceChildren(pager({page:eventPage,size:eventSize,total:eventTotal,noun:'envios',
|
||||
onPage:n=>{eventPage=n;loadEvents().catch(e=>say(e.message,true));},
|
||||
@@ -1673,7 +1671,6 @@ function renderIntegrations(){
|
||||
// Each carrier charges the larger of the real and the cubed weight.
|
||||
node('p','No carrinho o cliente vê todas as opções, da mais barata para a mais cara, com o prazo. Cada transportadora cobra o maior entre o peso real e o cubado.')]})
|
||||
: integration({name:'Frete',state:'Não configurado',tone:'off',summary:'Somente retirada.'}));
|
||||
rows.push(integration({name:'WhatsApp',state:'Não configurado',tone:'off',summary:'Mensagens registradas, sem envio.'}));
|
||||
rows.push(mailRow(board.providers?.mail||{}));
|
||||
const bk=board.providers?.backup||{};
|
||||
const ontem=bk.last_ok&&Date.now()-new Date(bk.last_ok)<26*3600e3;
|
||||
|
||||
Reference in New Issue
Block a user