diff --git a/src/app/dashboard/integrations/page.tsx b/src/app/dashboard/integrations/page.tsx new file mode 100644 index 0000000..2a7f110 --- /dev/null +++ b/src/app/dashboard/integrations/page.tsx @@ -0,0 +1,150 @@ +'use client'; + +import { useQuery } from '@tanstack/react-query'; +import Link from 'next/link'; +import { apiFetch } from '../../../lib/api'; +import { useSession } from '../../../components/session-provider'; + +interface DataSource { + id: string; name: string; sourceType: string; description: string | null; + status: 'active' | 'paused' | 'error' | 'archived'; lastSyncAt: string | null; + recordCount: number | null; createdAt: string; +} + +const NATIVE_INTEGRATIONS = [ + { key: 'clickhouse', name: 'ClickHouse (supersrv)', icon: '🗄️', category: 'Database', status: 'connected', description: 'Business intelligence — 147M+ rânduri, date companiei, ESCO.' }, + { key: 'anythingllm', name: 'AnythingLLM', icon: '🤖', category: 'AI / RAG', status: 'connected', description: 'Agenți AI și workspace-uri peste ClickHouse via MCP.' }, + { key: 'hermes', name: 'Hermes (CEO-OS AI)', icon: '⚡', category: 'AI', status: 'connected', description: 'Router inteligent Gemini/OpenRouter pentru toate request-urile AI.' }, + { key: 'forgejo', name: 'Forgejo (Git)', icon: '🔀', category: 'DevOps', status: 'connected', description: 'Repo de cod — ceo-api + ceo-web, CI/CD via Coolify.' }, + { key: 'coolify', name: 'Coolify', icon: '🚀', category: 'DevOps', status: 'connected', description: 'Deploy automat la push — staging + production.' }, + { key: 'openrouter', name: 'OpenRouter', icon: '🌐', category: 'AI', status: 'connected', description: 'Fallback LLM routing pentru modele multiple.' }, + { key: 'n8n', name: 'n8n Workflows', icon: '⚙️', category: 'Automation', status: 'connected', description: '8179 template-uri de automatizare disponibile.' }, + { key: 'metabase', name: 'Metabase', icon: '📊', category: 'Analytics', status: 'connected', description: 'Dashboard-uri BI pe date ClickHouse (OSS, fără AI).' }, +]; + +const PLANNED_INTEGRATIONS = [ + { key: 'gmail', name: 'Gmail', icon: '📧', category: 'Email', description: 'Sincronizare email și automatizare răspunsuri.' }, + { key: 'gcal', name: 'Google Calendar', icon: '📅', category: 'Productivity', description: 'Sincronizare evenimente și meetings.' }, + { key: 'notion', name: 'Notion', icon: '📝', category: 'Productivity', description: 'Export și sincronizare documente.' }, + { key: 'slack', name: 'Slack', icon: '💬', category: 'Communication', description: 'Notificări și comenzi din Slack.' }, + { key: 'stripe', name: 'Stripe', icon: '💳', category: 'Payments', description: 'Sincronizare plăți și facturare.' }, + { key: 'hubspot', name: 'HubSpot', icon: '🎯', category: 'CRM', description: 'Sincronizare contacte și pipeline CRM.' }, +]; + +const STATUS_CLS: Record = { + active: 'bg-signal-ok/10 text-signal-ok', connected: 'bg-signal-ok/10 text-signal-ok', + paused: 'bg-warn/10 text-warn', error: 'bg-signal-danger/10 text-signal-danger', + archived: 'bg-muted text-ink-faint', +}; + +export default function IntegrationsPage() { + const { activeTenant } = useSession(); + const tenantId = activeTenant?.tenantId ?? ''; + + const { data: sources = [] } = useQuery({ + queryKey: ['data-sources', tenantId], + queryFn: () => apiFetch('/v1/data-sources', { tenantId }), + enabled: Boolean(tenantId), staleTime: 60_000, + }); + + const activeSources = sources.filter((s) => s.status === 'active'); + const errorSources = sources.filter((s) => s.status === 'error'); + + return ( +
+
+

Integrări

+

+ {NATIVE_INTEGRATIONS.length} sisteme native conectate · {activeSources.length} surse de date active + {errorSources.length > 0 && {errorSources.length} erori} +

+
+ + {/* Native/infrastructure integrations */} +
+

Infrastructură & AI

+
+ {NATIVE_INTEGRATIONS.map((integration) => ( +
+ {integration.icon} +
+
+

{integration.name}

+ + {integration.status} + +
+

{integration.category}

+

{integration.description}

+
+
+ ))} +
+
+ + {/* User-added data sources */} + {sources.length > 0 && ( +
+
+

Surse de date înregistrate

+ Gestionează → +
+
+ {sources.map((s) => ( +
+
+

{s.name}

+

{s.sourceType} {s.lastSyncAt ? `· sincronizat ${new Date(s.lastSyncAt).toLocaleDateString('ro-RO')}` : ''}

+
+
+ {s.recordCount != null && ( + {s.recordCount.toLocaleString('ro-RO')} + )} + + {s.status} + +
+
+ ))} +
+
+ )} + + {/* Planned integrations */} +
+

Viitoare integrări

+
+ {PLANNED_INTEGRATIONS.map((integration) => ( +
+ {integration.icon} +
+
+

{integration.name}

+ planificat +
+

{integration.category}

+

{integration.description}

+
+
+ ))} +
+
+ + {/* Quick links */} +
+

Acțiuni rapide

+
+ + + Adaugă sursă de date + + + Registry date + + + Export date + +
+
+
+ ); +}