import { useEffect, useState } from 'react' import { Plus, Trash2, RefreshCw } from 'lucide-react' import api from '../lib/api' interface EpgSource { id: number; name: string; url: string; is_active: boolean; last_fetched_at: string | null } export default function EPG() { const [sources, setSources] = useState([]) const [showForm, setShowForm] = useState(false) const [form, setForm] = useState({ name: '', url: '' }) const [refreshing, setRefreshing] = useState(false) async function load() { const { data } = await api.get('/epg/') setSources(data) } useEffect(() => { load() }, []) async function submit(e: React.FormEvent) { e.preventDefault() await api.post('/epg/', form) setForm({ name: '', url: '' }) setShowForm(false) load() } async function del(id: number) { if (!confirm('¿Eliminar fuente EPG?')) return await api.delete(`/epg/${id}`) load() } async function refresh() { setRefreshing(true) try { await api.post('/epg/refresh') alert('EPG actualización iniciada en segundo plano') } finally { setRefreshing(false) } } return (

Gestión EPG

Endpoint EPG para tus apps IPTV:
http://10.10.10.234/xmltv.php?username=USUARIO&password=CONTRASEÑA
{showForm && (

Nueva fuente XMLTV

setForm(f => ({ ...f, name: e.target.value }))} required className="w-full bg-dark-700 border border-dark-600 rounded-lg px-3 py-2 text-sm" />
setForm(f => ({ ...f, url: e.target.value }))} required placeholder="http://proveedor.com/xmltv.php?username=X&password=Y" className="w-full bg-dark-700 border border-dark-600 rounded-lg px-3 py-2 text-sm" />
)}
{sources.map(s => (
{s.name}
{s.url}
{s.last_fetched_at && (
Última actualización: {new Date(s.last_fetched_at).toLocaleString('es-ES')}
)}
))} {sources.length === 0 && (
No hay fuentes EPG configuradas
)}
) }