import React, { useState } from 'react'; import { Card } from '../ui/card'; import { Button } from '../ui/button'; import { Input } from '../ui/input'; import { Radio, Plus, Trash2, Zap, AlertTriangle } from 'lucide-react'; import { useToast } from '../../context/ToastContext'; interface Webhook { id: string; url: string; events: string[]; status: 'active' | 'failed'; lastTriggered: string; } const MOCK_WEBHOOKS: Webhook[] = [ { id: 'w1', url: 'https://api.myapp.com/veza-hook', events: ['track.upload', 'user.update'], status: 'active', lastTriggered: '2 hours ago', }, { id: 'w2', url: 'https://hooks.slack.com/services/T000...', events: ['sales.new'], status: 'failed', lastTriggered: '1 day ago', }, ]; export const WebhooksView: React.FC = () => { const { addToast } = useToast(); const [webhooks, setWebhooks] = useState(MOCK_WEBHOOKS); const [newUrl, setNewUrl] = useState(''); const handleCreate = () => { if (!newUrl) return; const newHook: Webhook = { id: `w-${Date.now()}`, url: newUrl, events: ['all'], status: 'active', lastTriggered: 'Never', }; setWebhooks([...webhooks, newHook]); setNewUrl(''); addToast('Webhook created', 'success'); }; const handleTest = (_id: string) => { addToast(`Sending test payload to webhook...`, 'info'); }; const handleDelete = (id: string) => { setWebhooks(webhooks.filter((w) => w.id !== id)); addToast('Webhook deleted', 'info'); }; return (

WEBHOOKS

Subscribe to real-time events.

Add Endpoint

setNewUrl(e.target.value)} className="flex-1" />
{webhooks.map((hook) => (
{hook.status === 'active' ? ( ) : ( )}
{hook.url}
Events: {hook.events.map((e) => ( {e} ))} Last Triggered: {hook.lastTriggered}
))}
); };