import { useState, useEffect } from 'react'; import { Puzzle, Check, Zap, Clock } from 'lucide-react'; import type { Integration } from '@/types/api'; import { getIntegrations } from '@/lib/api'; function statusBadge(status: Integration['status']) { switch (status) { case 'Active': return { icon: Check, label: 'Active', classes: 'text-[#00e68a] border-[#00e68a30]', bg: 'rgba(0,230,138,0.06)', }; case 'Available': return { icon: Zap, label: 'Available', classes: 'text-[#0080ff] border-[#0080ff30]', bg: 'rgba(0,128,255,0.06)', }; case 'ComingSoon': return { icon: Clock, label: 'Coming Soon', classes: 'text-[#556080] border-[#1a1a3e]', bg: 'rgba(26,26,62,0.3)', }; } } export default function Integrations() { const [integrations, setIntegrations] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const [activeCategory, setActiveCategory] = useState('all'); useEffect(() => { getIntegrations() .then(setIntegrations) .catch((err) => setError(err.message)) .finally(() => setLoading(false)); }, []); const categories = [ 'all', ...Array.from(new Set(integrations.map((i) => i.category))).sort(), ]; const filtered = activeCategory === 'all' ? integrations : integrations.filter((i) => i.category === activeCategory); // Group by category for display const grouped = filtered.reduce>((acc, item) => { const key = item.category; if (!acc[key]) acc[key] = []; acc[key].push(item); return acc; }, {}); if (error) { return (
Failed to load integrations: {error}
); } if (loading) { return (
); } return (
{/* Header */}

Integrations ({integrations.length})

{/* Category Filter Tabs */}
{categories.map((cat) => ( ))}
{/* Grouped Integration Cards */} {Object.keys(grouped).length === 0 ? (

No integrations found.

) : ( Object.entries(grouped) .sort(([a], [b]) => a.localeCompare(b)) .map(([category, items]) => (

{category}

{items.map((integration) => { const badge = statusBadge(integration.status); const BadgeIcon = badge.icon; return (

{integration.name}

{integration.description}

{badge.label}
); })}
)) )}
); }