implement shuffle topics button functionality

This commit is contained in:
Sanjay Bhangar 2018-12-13 16:22:58 +02:00
parent 9fe634dfd5
commit c4603b8e03
2 changed files with 10 additions and 2 deletions

View File

@ -6,6 +6,10 @@ import RandomItemTitle from "./SectionHeading";
class RandomTopic extends React.Component { class RandomTopic extends React.Component {
shuffleTopic() {
this.props.getRandomTopicVideos(this.props.allTopics);
}
render() { render() {
return ( return (
<section> <section>
@ -24,7 +28,7 @@ class RandomTopic extends React.Component {
</button> </button>
{/* Shuffle button */} {/* Shuffle button */}
<button className="shuffle-button" onClick=""> <button className="shuffle-button" onClick={ this.shuffleTopic.bind(this) }>
<span className="english-text">Shuffle Topics - </span> <span className="english-text">Shuffle Topics - </span>
<span className="arabic-text"> موضوع عشوائي </span> <span className="arabic-text"> موضوع عشوائي </span>
<i className="fa fa-random"></i> <i className="fa fa-random"></i>
@ -52,9 +56,11 @@ class RandomTopic extends React.Component {
RandomTopic.propTypes = { RandomTopic.propTypes = {
topicName: PropTypes.string, topicName: PropTypes.string,
allTopics: PropTypes.array,
videos: PropTypes.array, videos: PropTypes.array,
loading: PropTypes.bool, loading: PropTypes.bool,
topicCount: PropTypes.number topicCount: PropTypes.number,
getRandomTopicVideos: PropTypes.func
}; };
export default (RandomTopic); export default (RandomTopic);

View File

@ -30,9 +30,11 @@ class Home extends React.Component {
<div> <div>
<RandomTopic <RandomTopic
topicName={ this.props.randomTopic || ''} topicName={ this.props.randomTopic || ''}
allTopics={ this.props.allTopics || [] }
topicCount={ this.props.randomTopicCount } topicCount={ this.props.randomTopicCount }
videos = { this.props.randomTopicVideos || [] } videos = { this.props.randomTopicVideos || [] }
loading = { this.props.loadingAllTopics || this.props.loadingRandomTopic } loading = { this.props.loadingAllTopics || this.props.loadingRandomTopic }
getRandomTopicVideos={ this.props.getRandomTopicVideos }
/> />
<RandomLocation/> <RandomLocation/>
<RandomDate/> <RandomDate/>