import React, { Component } from 'react' import { Link } from 'react-router-dom' import { connect } from 'react-redux' import { Loader } from 'app/common' import actions from 'app/actions' import UserMenu from '../components/user.menu' // const { result, collectionLookup } = this.props class UserIndex extends Component { componentDidMount() { this.fetch() } fetch() { actions.user.index() } render() { const { currentUser } = this.props const { loading, lookup, order } = this.props.user.index if (loading) { return ( ) } if (!lookup || !order.length) { return ( Users {"No users"} ) } return ( Users {order.map(id => { const user = lookup[id] return ( {(currentUser.is_admin || currentUser.id === user.id) ? {user.username} : user.username } {user.is_admin && " (admin)"} ) })} {order.length >= 50 && this.fetch(true)}>Load More} ) } } const mapStateToProps = state => ({ user: state.user, currentUser: state.auth.user, }) export default connect(mapStateToProps)(UserIndex)
{"No users"}