2017-11-13 19:37:43 +00:00
|
|
|
import React from 'react'
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
|
2018-12-17 16:34:32 +00:00
|
|
|
const CharacterInfo = ({
|
|
|
|
character,
|
|
|
|
error,
|
|
|
|
fetchCharacter,
|
|
|
|
isFetchedOnServer = false
|
|
|
|
}) => (
|
2017-11-13 19:37:43 +00:00
|
|
|
<div className='CharacterInfo'>
|
2018-12-17 16:34:32 +00:00
|
|
|
{error ? (
|
|
|
|
<p>We encountered and error.</p>
|
|
|
|
) : (
|
|
|
|
<article>
|
|
|
|
<h3>Character: {character.name}</h3>
|
|
|
|
<p>birth year: {character.birth_year}</p>
|
|
|
|
<p>gender: {character.gender}</p>
|
|
|
|
<p>skin color: {character.skin_color}</p>
|
|
|
|
<p>eye color: {character.eye_color}</p>
|
|
|
|
</article>
|
|
|
|
)}
|
2017-11-13 19:37:43 +00:00
|
|
|
<p>
|
2018-12-17 16:34:32 +00:00
|
|
|
(was character fetched on server? - <b>{isFetchedOnServer.toString()})</b>
|
2017-11-13 19:37:43 +00:00
|
|
|
</p>
|
|
|
|
<style jsx>{`
|
|
|
|
article {
|
2018-12-17 16:34:32 +00:00
|
|
|
background-color: #528ce0;
|
2017-11-13 19:37:43 +00:00
|
|
|
border-radius: 15px;
|
|
|
|
padding: 15px;
|
|
|
|
width: 250px;
|
|
|
|
margin: 15px 0;
|
|
|
|
color: white;
|
|
|
|
}
|
|
|
|
button {
|
|
|
|
margin-right: 10px;
|
|
|
|
}
|
|
|
|
`}</style>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
|
2018-12-17 16:34:32 +00:00
|
|
|
export default connect(state => ({
|
|
|
|
character: state.character,
|
|
|
|
error: state.error,
|
|
|
|
isFetchedOnServer: state.isFetchedOnServer
|
|
|
|
}))(CharacterInfo)
|