import { ArrowPathIcon, CheckCircleIcon, ExclamationTriangleIcon, XMarkIcon, } from '@heroicons/react/24/outline'; import { useEffect, useState } from 'react'; import { ExchangesTable } from './components/ExchangesTable'; import { useExchanges } from './hooks/useExchanges'; export function ExchangesPage() { const { syncExchanges } = useExchanges(); const [syncing, setSyncing] = useState(false); const [syncStatus, setSyncStatus] = useState<{ type: 'success' | 'error' | null; message: string; }>({ type: null, message: '' }); // Auto-dismiss success messages after 5 seconds useEffect(() => { if (syncStatus.type === 'success') { const timer = setTimeout(() => { setSyncStatus({ type: null, message: '' }); }, 5000); return () => clearTimeout(timer); } }, [syncStatus.type]); const handleSync = async () => { setSyncing(true); setSyncStatus({ type: null, message: '' }); try { const result = await syncExchanges(); if (result) { setSyncStatus({ type: 'success', message: `Exchange sync completed successfully! Job ID: ${result.jobId || 'Unknown'}`, }); } else { setSyncStatus({ type: 'error', message: 'Sync failed - no result returned from server', }); } } catch (error) { setSyncStatus({ type: 'error', message: error instanceof Error ? error.message : 'Sync failed with unknown error', }); } finally { setSyncing(false); } }; return (
Configure and manage master exchanges with their data sources and providers.
{syncStatus.type === 'success' ? 'Sync Completed' : 'Sync Failed'}
{syncStatus.message}