import React, { useState, useEffect } from 'react'; import { Card } from '../ui/card'; import { Button } from '../ui/button'; import { Input } from '../ui/input'; import { Plus, Trash2, Zap, Terminal, Activity, Loader2 } from 'lucide-react'; import { useToast } from '../../components/feedback/ToastProvider'; import { cn } from '@/lib/utils'; import { webhookService, Webhook } from '../../services/webhookService'; export const WebhooksView: React.FC = () => { const { addToast } = useToast(); const [webhooks, setWebhooks] = useState([]); const [loading, setLoading] = useState(true); const [newUrl, setNewUrl] = useState(''); const fetchWebhooks = async () => { setLoading(true); try { const data = await webhookService.list(); setWebhooks(data); } catch (e) { addToast('Failed to load webhooks', 'error'); } finally { setLoading(false); } }; useEffect(() => { fetchWebhooks(); }, []); const handleCreate = async () => { if (!newUrl) return; try { await webhookService.create(newUrl); setNewUrl(''); addToast('Webhook generated successfully', 'success'); fetchWebhooks(); } catch (e) { addToast('Failed to create webhook', 'error'); } }; const handleTest = (_id: string) => { addToast(`Sending test payload to endpoint...`, 'info'); }; const handleDelete = async (id: string) => { try { await webhookService.delete(id); setWebhooks(webhooks.filter((w) => w.id !== id)); addToast('Webhook disconnected', 'info'); } catch (e) { addToast('Failed to delete webhook', 'error'); } }; return (

Webhooks

EVENT SUBSCRIPTION PROTOCOL

Register Endpoint

setNewUrl(e.target.value)} className="flex-1 font-mono text-sm" />
{loading ? (
) : webhooks.length === 0 ? (

No endpoints registered

Ready to stream real-time events to your external infra.

) : ( webhooks.map((hook) => ( {/* Status Indicator Bar */}
{hook.status}
{hook.url}
events: {hook.events.map(e => {e})}
Last trigger: {hook.lastTriggered}
)) )}
); };