import classNames from 'classnames' import { useState, useEffect } from 'react' import { UI_STATE } from '../TransactionUI/useTransaction' export default function HostStatusIndicator({ state, }: { state: UI_STATE | null }) { const [lastStatusStr, setLastStatusStr] = useState('') useEffect(() => { let statusStr = '' if ( state === 'COMPLETED' || state === 'USURPED' || // usurped is still online state === 'IN_PROGRESS' ) { statusStr = 'Connected' } else if (state === 'HOST_DROPPED') { statusStr = 'Reconnecting...' } else if ( state === 'HOST_NOT_FOUND' || state === 'SERVER_DROPPED' || state === 'IDLE' ) { statusStr = 'Offline' } else if (state === 'CONNECTING') { statusStr = 'Connecting' } if (statusStr) setLastStatusStr(statusStr) }, [state]) return (