import React from 'react';
import {connect} from 'react-redux';
import testAction from '../actions/test';
import fetchVideos from '../actions/fetchVideos';
import Search from '../components/Search';
import Footer from '../components/Footer';
import RandomLocation from "../components/RandomLocation";
import RandomDate from "../components/RandomDate";
import RandomTopic from "../components/RandomTopic";
import Header from "../components/Header";
class Home extends React.Component {
  clickBtn() {
    this.props.testAction('some new value');
  }

  render() {
    return (
      <div>
        <Search/>
        <RandomTopic/>
        <RandomLocation/>
        <RandomDate/>
      </div>
    );
    //
    // <div>
    //   This is home. {this.props.test}
    //   <div>
    //     <Link to="/topics">Go to topics</Link>
    //   </div>
    //   <div>
    //     <button onClick={this.clickBtn.bind(this)}>Click me</button>
    //     <button onClick={this.props.fetchVideos}>Fetch videos</button>
    //   </div>
    //   <div>
    //     {this.props.loading && 'Loading...'}
    //     {this.props.videos.map(video => {
    //       return (<div key={video.id}>{video.title}</div>);
    //     })}
    //   </div>
    // </div>
  }
}

const mapStateToProps = state => ({
  test: state.home.test,
  loading: state.home.loading,
  videos: state.home.videos
});

const mapDispatchToProps = dispatch => ({
  testAction: value => dispatch(testAction(value)),
  fetchVideos: () => dispatch(fetchVideos())
});

export default connect(mapStateToProps, mapDispatchToProps)(Home);