Created
May 13, 2018 17:16
-
-
Save jamestthompson3/3007a6d6309893c53543be60022d5754 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { PageWrapper, ListContainer, ListItem, Loader, UserContainer } from './styledComponents' | |
const IndexPage = ({ status, userList, selectedUser, userSelect, message, match, history }) => { | |
const userParam = get(match, 'params.user') | |
if (selectedUser) { | |
userParam !== selectedUser.user && history.push(`/${selectedUser.user}`) | |
} | |
return ( | |
<PageWrapper> | |
<UserContainer> | |
{status === 'SUCCESS' ? ( | |
<Fragment> | |
<h3>Users</h3> | |
<ListContainer style={{ height: '500px' }}> | |
{userList.map((user, i) => ( | |
<ListItem key={i} onClick={() => userSelect(user)} selected={user === selectedUser}> | |
<p>{user.user}</p> | |
</ListItem> | |
))} | |
</ListContainer> | |
</Fragment> | |
) : ( | |
<Loader status={status} message={message} /> | |
)} | |
</UserContainer> | |
</PageWrapper> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment