Skip to content

Instantly share code, notes, and snippets.

@jamestthompson3
Created May 13, 2018 17:16
Show Gist options
  • Save jamestthompson3/3007a6d6309893c53543be60022d5754 to your computer and use it in GitHub Desktop.
Save jamestthompson3/3007a6d6309893c53543be60022d5754 to your computer and use it in GitHub Desktop.
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