// Grape Elevate — Automations list screen const TriggerIcon = ({ type, size = 14 }) => { const map = { comment: , story: , follow: , dm: }; return map[type] || ; }; const triggerLabel = (a) => ({ comment: 'Comentário', story: 'Story reply', follow: 'Novo seguidor', dm: 'DM recebida' }[a.trigger] || a.trigger); function AutomationRow({ a, t, onToggle, onEdit, onDup, onDelete, onOpen }) { const statusPill = a.status === 'live' ? 'pill-live' : a.status === 'paused' ? 'pill-paused' : 'pill-draft'; return (
{a.name}
Atualizado {a.updated}
{triggerLabel(a)} {a.triggerKey !== '—' && "{a.triggerKey}"}
{a.runs.toLocaleString('pt-BR')}
{a.conv.toFixed(1)}%
{a.status === 'live' && } {t(`auto.status.${a.status === 'live' ? 'live' : a.status === 'paused' ? 'paused' : 'draft'}`)}
e.stopPropagation()}>
); } function Automations({ t, automations, setAutomations, onNav, onOpenFlow }) { const [filter, setFilter] = React.useState('all'); const [q, setQ] = React.useState(''); const filtered = automations.filter((a) => { if (filter === 'on' && a.status !== 'live') return false; if (filter === 'off' && a.status !== 'paused') return false; if (filter === 'drafts' && a.status !== 'draft') return false; if (q && !a.name.toLowerCase().includes(q.toLowerCase())) return false; return true; }); const toggle = (a) => setAutomations((xs) => xs.map((x) => x.id === a.id ? { ...x, status: x.status === 'live' ? 'paused' : 'live' } : x)); const dup = (a) => setAutomations((xs) => [...xs, { ...a, id: 'a' + Date.now(), name: a.name + ' (cópia)', status: 'draft', runs: 0, conv: 0, updated: 'agora' }]); const del = (a) => setAutomations((xs) => xs.filter((x) => x.id !== a.id)); return ( <>

{t('auto.title')}

{t('auto.subtitle')}

setQ(e.target.value)} style={{ width: 240 }} />
{[['all', t('auto.filter.all')], ['on', t('auto.filter.on')], ['off', t('auto.filter.off')], ['drafts', t('auto.filter.drafts')]].map(([k, l]) => ( ))}
Ordenar por: Execuções ▾
{t('auto.col.name')}
{t('auto.col.trigger')}
{t('auto.col.runs')}
{t('auto.col.conv')}
{t('auto.col.status')}
{filtered.length === 0 ? (
{t('auto.empty')}
) : filtered.map((a) => ( onOpenFlow(a.id)} onDup={() => dup(a)} onDelete={() => del(a)} onOpen={() => onOpenFlow(a.id)} /> ))}
); } const autoStyles = ` .auto-table { padding: 0; overflow: hidden; } .auto-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.3fr) 100px minmax(0, 1fr) 110px 180px; gap: 16px; padding: 14px 18px; align-items: center; border-bottom: 1px solid var(--line); cursor: pointer; transition: background 120ms; } .auto-row:last-child { border-bottom: 0; } .auto-row:hover { background: var(--surface-2); } .auto-head { background: var(--surface-2); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-mute); cursor: default; padding-top: 12px; padding-bottom: 12px; } .auto-head:hover { background: var(--surface-2); } .auto-name { display: flex; align-items: center; gap: 12px; min-width: 0; } .auto-emoji { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: var(--text); } .auto-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .auto-trigger { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; } .trigger-key { font-size: 11.5px; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); color: var(--coral); } .auto-runs { font-variant-numeric: tabular-nums; font-weight: 600; } .auto-conv { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--text-soft); } .conv-bar { flex: 1; height: 5px; background: var(--surface-3); border-radius: 999px; overflow: hidden; min-width: 40px; } .conv-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--grape)); border-radius: 999px; } .auto-actions { display: flex; align-items: center; gap: 4px; justify-content: flex-end; } .seg-count { font-size: 11px; opacity: 0.65; margin-left: 4px; } `; window.Automations = Automations;