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 {
shuffleTopic() {
this.props.getRandomTopicVideos(this.props.allTopics);
}
render() {
return (
<section>
@ -24,7 +28,7 @@ class RandomTopic extends React.Component {
</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="arabic-text"> موضوع عشوائي </span>
<i className="fa fa-random"></i>
@ -52,9 +56,11 @@ class RandomTopic extends React.Component {
RandomTopic.propTypes = {
topicName: PropTypes.string,
allTopics: PropTypes.array,
videos: PropTypes.array,
loading: PropTypes.bool,
topicCount: PropTypes.number
topicCount: PropTypes.number,
getRandomTopicVideos: PropTypes.func
};
export default (RandomTopic);

View File

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