Files
Iris/src/js/views/discover/Discover.js

70 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-10-26 16:55:47 +13:00
import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import Header from '../../components/Header'
import GridSlider from '../../components/GridSlider'
import ArtistSentence from '../../components/ArtistSentence'
2016-10-26 16:55:47 +13:00
import * as helpers from '../../helpers'
2016-10-26 16:55:47 +13:00
import * as spotifyActions from '../../services/spotify/actions'
class Discover extends React.Component{
constructor(props) {
super(props);
}
componentDidMount(){
this.props.spotifyActions.getDiscover()
}
renderRecommendations(){
if (!this.props.discover || this.props.discover.length <= 0) return null
return (
<section className="recommendations">
{
this.props.discover.map(
(discover, index) => {
2017-01-12 08:52:21 +13:00
var title = <h4>Because you listened to <ArtistSentence artists={discover.seed.artists} /></h4>
return <GridSlider title={title} tracks={discover.tracks} key={index} />
}
)
}
</section>
)
}
2016-10-26 16:55:47 +13:00
render(){
return (
<div className="view discover-view">
<Header icon="compass" title="Discover" />
{ this.renderRecommendations() }
</div>
)
2016-10-26 16:55:47 +13:00
}
}
/**
* Export our component
*
* We also integrate our global store, using connect()
**/
const mapStateToProps = (state, ownProps) => {
return {
authorized: state.spotify.authorized,
discover: state.spotify.discover
}
2016-10-26 16:55:47 +13:00
}
const mapDispatchToProps = (dispatch) => {
return {
spotifyActions: bindActionCreators(spotifyActions, dispatch)
}
}
export default connect(mapStateToProps, mapDispatchToProps)(Discover)