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'
|
2017-01-11 13:52:55 +13:00
|
|
|
import GridSlider from '../../components/GridSlider'
|
|
|
|
|
import ArtistSentence from '../../components/ArtistSentence'
|
2016-10-26 16:55:47 +13:00
|
|
|
|
2016-11-19 13:06:08 +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);
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-11 13:52:55 +13:00
|
|
|
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} />
|
2017-01-11 13:52:55 +13:00
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
</section>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-26 16:55:47 +13:00
|
|
|
render(){
|
2016-11-19 13:06:08 +13:00
|
|
|
return (
|
|
|
|
|
<div className="view discover-view">
|
|
|
|
|
<Header icon="compass" title="Discover" />
|
2017-01-11 13:52:55 +13:00
|
|
|
{ this.renderRecommendations() }
|
2016-11-19 13:06:08 +13:00
|
|
|
</div>
|
|
|
|
|
)
|
2016-10-26 16:55:47 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Export our component
|
|
|
|
|
*
|
|
|
|
|
* We also integrate our global store, using connect()
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
2016-11-19 13:06:08 +13:00
|
|
|
return {
|
2017-01-11 13:52:55 +13:00
|
|
|
authorized: state.spotify.authorized,
|
|
|
|
|
discover: state.spotify.discover
|
2016-11-19 13:06:08 +13:00
|
|
|
}
|
2016-10-26 16:55:47 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
|
|
|
return {
|
|
|
|
|
spotifyActions: bindActionCreators(spotifyActions, dispatch)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Discover)
|