'use client'; import React, { useState } from 'react'; import { Activity, CheckCircle, Clock, XCircle, Zap, Filter } from 'lucide-react'; interface LogEntry { id: string; timestamp: string; campaign_name: string; rule_name: string; action: string; details: string; status: 'executed' | 'pending' | 'failed' | 'skipped'; } // Demo data (will be replaced with Supabase query) const DEMO_LOGS: LogEntry[] = [ { id: '1', timestamp: new Date(Date.now() - 3600000).toISOString(), campaign_name: 'Campanha Conversão Q1', rule_name: 'CPL Alto — Pausar', action: 'pause', details: 'CPL = R$67.30 (threshold: R$50.00)', status: 'executed', }, { id: '2', timestamp: new Date(Date.now() - 7200000).toISOString(), campaign_name: 'Remarketing Visitantes', rule_name: 'ROAS Baixo — Pausar', action: 'pause', details: 'ROAS = 0.32x (threshold: 0.50x)', status: 'executed', }, { id: '3', timestamp: new Date(Date.now() - 14400000).toISOString(), campaign_name: 'Tráfego Blog', rule_name: 'CTR Muito Baixo — Pausar', action: 'pause', details: 'CTR = 0.21% (threshold: 0.50%)', status: 'executed', }, { id: '4', timestamp: new Date(Date.now() - 28800000).toISOString(), campaign_name: 'Leads Premium', rule_name: 'ROAS Excelente — Aumentar Budget', action: 'increase_budget', details: 'Budget +20%: R$50.00 → R$60.00. ROAS = 4.2x', status: 'executed', }, { id: '5', timestamp: new Date(Date.now() - 43200000).toISOString(), campaign_name: 'Campanha Vídeo', rule_name: 'CPC Alto — Reduzir Budget', action: 'reduce_budget', details: 'Em cooldown (48h)', status: 'skipped', }, ]; const statusConfig = { executed: { icon: , color: '#4ade80', bg: 'rgba(34,197,94,0.1)', label: 'Executado' }, pending: { icon: , color: '#fbbf24', bg: 'rgba(245,158,11,0.1)', label: 'Pendente' }, failed: { icon: , color: '#f87171', bg: 'rgba(239,68,68,0.1)', label: 'Falhou' }, skipped: { icon: , color: '#8888a0', bg: 'var(--overlay-05)', label: 'Pulado' }, }; function timeAgo(dateStr: string): string { const diff = Date.now() - new Date(dateStr).getTime(); const mins = Math.floor(diff / 60000); if (mins < 60) return `${mins}min atrás`; const hours = Math.floor(mins / 60); if (hours < 24) return `${hours}h atrás`; const days = Math.floor(hours / 24); return `${days}d atrás`; } export default function ActivityPage() { const [filter, setFilter] = useState('all'); const logs = filter === 'all' ? DEMO_LOGS : DEMO_LOGS.filter((l) => l.status === filter); return (
{/* Header */}

Atividade

Ações executadas pelo agente de automação

{['all', 'executed', 'pending', 'skipped', 'failed'].map((f) => ( ))}
{/* Stats */}
{[ { label: 'Total', value: DEMO_LOGS.length, color: 'var(--accent-soft-fg)' }, { label: 'Executados', value: DEMO_LOGS.filter((l) => l.status === 'executed').length, color: '#4ade80' }, { label: 'Pendentes', value: DEMO_LOGS.filter((l) => l.status === 'pending').length, color: '#fbbf24' }, { label: 'Pulados', value: DEMO_LOGS.filter((l) => l.status === 'skipped').length, color: '#8888a0' }, ].map((s) => (

{s.value}

{s.label}

))}
{/* Timeline */}

Timeline

{logs.length === 0 ? (

Nenhuma atividade encontrada

) : ( logs.map((log) => { const sc = statusConfig[log.status]; return (
{/* Timeline dot */}
{/* Content */}

{log.campaign_name}

{sc.icon} {sc.label}

Regra: {log.rule_name}

{log.details}

{/* Time */} {timeAgo(log.timestamp)}
); }) )}
); }