import { useEffect, useRef, useSyncExternalStore } from 'react' import { useTranslation } from 'react-i18next' import { EXPLORER } from '../config/addresses' import { txlog, type LogLine } from '../lib/txlog' function glyph(l: LogLine): string { switch (l.kind) { case 'ok': return '✓' case 'err': return '✗' case 'pending': return '⧗' default: return '>' } } export function TxLogPanel() { const { t } = useTranslation() const lines = useSyncExternalStore(txlog.subscribe, txlog.get) const ref = useRef(null) useEffect(() => { const el = ref.current if (el) el.scrollTop = el.scrollHeight }, [lines]) return (
{lines.length === 0 &&
{t('log.ready')}
} {lines.length > 2 && (
-------- {t('log.events', { n: lines.length })}
)} {lines.map((l) => (
{new Date(l.ts).toLocaleTimeString('en-GB')} {glyph(l)} {l.text} {l.hash && ( tx↗ )} {l.action && ( )}
))}
) }