import React, { PureComponent } from 'react'; import { FormattedTime, defineMessages, injectIntl } from 'react-intl'; import PropTypes from 'prop-types'; import cx from 'classnames'; import UserAvatar from '/imports/ui/components/user-avatar/component'; import SlowConnection from '/imports/ui/components/slow-connection/component'; import Modal from '/imports/ui/components/modal/simple/component'; import { styles } from './styles'; const intlMessages = defineMessages({ ariaTitle: { id: 'app.connection-status.ariaTitle', description: 'Connection status aria title', }, title: { id: 'app.connection-status.title', description: 'Connection status title', }, description: { id: 'app.connection-status.description', description: 'Connection status description', }, empty: { id: 'app.connection-status.empty', description: 'Connection status empty', }, }); const propTypes = { closeModal: PropTypes.func.isRequired, intl: PropTypes.shape({ formatMessage: PropTypes.func.isRequired, }).isRequired, }; class ConnectionStatusComponent extends PureComponent { renderEmpty() { const { intl } = this.props; return (
{intl.formatMessage(intlMessages.empty)}
); } renderConnections() { const { connectionStatus } = this.props; if (connectionStatus.length === 0) return this.renderEmpty(); return connectionStatus.map((conn, index) => { const dateTime = new Date(conn.timestamp); const itemStyle = {}; itemStyle[styles.even] = index % 2 === 0; return (
{conn.name.toLowerCase().slice(0, 2)}
{conn.name}
); }); } render() { const { closeModal, connectionStatus, intl, } = this.props; return (

{intl.formatMessage(intlMessages.title)}

{intl.formatMessage(intlMessages.description)}
{this.renderConnections()}
); } } ConnectionStatusComponent.propTypes = propTypes; export default injectIntl(ConnectionStatusComponent);