import { useState, useEffect } from 'react' import { getEventDefs } from '../api' import { Spinner, EmptyState, HashBadge } from './Common' import EmitEventModal from './EmitEventModal' export default function EventDefs() { const [data, setData] = useState>([]) const [expanded, setExpanded] = useState>(new Set()) const [error, setError] = useState('') const [loading, setLoading] = useState(true) const [emitTarget, setEmitTarget] = useState<{ name: string; schema: any } | null>(null) const fetchData = () => { setLoading(true) getEventDefs() .then((res) => setData(res.event_defs)) .catch((e) => setError(e.message)) .finally(() => setLoading(false)) } useEffect(() => { fetchData() }, []) const toggleExpand = (hash: string) => { setExpanded((prev) => { const next = new Set(prev) if (next.has(hash)) { next.delete(hash) } else { next.add(hash) } return next }) } if (loading) return if (error) return
Error: {error}
return (

Event Definitions

{data.length === 0 ? ( ) : (
{data.map((def, i) => ( ))}
Name Hash Parent Schema Actions
{def.name} {def.parent_hash ? : -} {expanded.has(def.hash) && (
                        {JSON.stringify(def.schema, null, 2)
                          .split('\n')
                          .map((line, i) => {
                            if (line.includes(':')) {
                              const [key, ...rest] = line.split(':')
                              return (
                                
{key}: {rest.join(':')}
) } return (
{line}
) })}
)}
)}
{emitTarget && ( setEmitTarget(null)} onSuccess={() => {}} /> )}
) }