import React, { Component } from 'react'; import { connect } from 'react-redux'; import selectTorrent, { UNION, SUBTRACT, EXCLUSIVE } from '../actions/selection'; import { formatBitrate } from '../bitrate'; class TorrentTable extends Component { render() { const { selection, torrents, dispatch } = this.props; return ( {Object.values(torrents).map(t => )}
{ if (selection.length > 0) { dispatch(selectTorrent([], EXCLUSIVE)); } else { dispatch(selectTorrent(Object.keys(torrents), EXCLUSIVE)); } }} /> name up down ratio
dispatch(selectTorrent([t.id], e.target.checked ? UNION : SUBTRACT)) } /> { e.preventDefault(); dispatch(selectTorrent([t.id], EXCLUSIVE)); }} >{t.name} {formatBitrate(t.rate_up)} {formatBitrate(t.rate_down)} {(t.transferred_up / t.transferred_down).toFixed(2)}
); } } export default connect(state => ({ torrents: state.torrents, selection: state.selection, router: state.router }))(TorrentTable);