import React from 'react'; import PropTypes from 'prop-types'; import { gettext } from '../../../utils/constants'; const propTypes = { type: PropTypes.string.isRequired, children: PropTypes.oneOfType([PropTypes.bool, PropTypes.array]), }; class TrafficTable extends React.Component { constructor(props) { super(props); this.state = { showIconName: 'link_file_download' }; } componentDidMount() { let { showIconName } = this.state; let { sortOrder } = this.props; this.props.sortBySize(showIconName, sortOrder); } sortBySize = (sortByType) => { let { sortOrder } = this.props; let newSortOrder = sortOrder === 'asc' ? 'desc' : 'asc'; this.setState({ showIconName: sortByType }); this.props.sortBySize(sortByType, newSortOrder); } render() { const { type, sortOrder } = this.props; const { showIconName } = this.state; const sortIcon = sortOrder == 'asc' ? : ; return ( {this.props.children}
{type == 'user' ? gettext('User') : gettext('Organization')}
{gettext('Sync Upload')} {showIconName === 'sync_file_upload' && sortIcon}
{gettext('Sync Download')} {showIconName === 'sync_file_donwload' && sortIcon}
{gettext('Web Upload')} {showIconName === 'web_file_upload' && sortIcon}
{gettext('Web Download')} {showIconName === 'web_file_download' && sortIcon}
{gettext('Share link upload')} {showIconName === 'link_file_upload' && sortIcon}
{gettext('Share link download')} {showIconName === 'link_file_download' && sortIcon}
); } } TrafficTable.propTypes = propTypes; export default TrafficTable;