import {connect} from "react-redux";
import {Link} from "react-router-dom";
import {actionUserFind} from "../../actions";
import {store} from "../../reducers";




const User = ({user:{_id, login}={}}) =>
<Link to={`/user/${_id}`}>
    <div className="box-3">
        <div className="btn btn-three">
            <span>{login}</span>
        </div>
    </div>
</Link>


const AllUsers = ({users={}}) =>{

        return (
            <div className='Users'>
                    {users.map(user =>  <User key={Math.random()} user={user}/> )}
            </div>
        )

}

export const CAllUsers = connect(state => ({users: state.promise.userFind?.payload || []}))
(AllUsers)


store.dispatch(actionUserFind())