import Grid from 'react-css-grid'
import React from 'react';
import PropTypes from 'prop-types';
import VideoItem from "./VideoItem";
import RandomItemTitle from "./SectionHeading";
import {Link} from 'react-router-dom';

class RandomPlace extends React.Component {

  shufflePlace() {
    this.props.getRandomPlaceVideos(this.props.allPlaces);
  }

  render() {
    return (
      <section className="random-item-container">
        <h2 className="section-heading">
          <span className="arabic-text random-section-title">من أماكن الارشيف</span>
          <br/>
          <span className="section-title">
          <span className='english-text bold-english-text random-section-title'> Places from the archive
        </span>
          </span>
        </h2>
        <Grid
          width={450}
        >
          {/* View all places button*/}
          <Link className="view-items-link" to="/places">
            <button className="view-all-items">
              <span className="english-text"> all places    &nbsp; </span>
              <span className="arabic-text"> 	 جميع الأماكن	</span>
            </button>
          </Link>
          {/* Shuffle button */}
          <button className="shuffle-button" onClick={this.shufflePlace.bind(this)}>
            <span className="english-text">Shuffle Places - </span>
            <span className="arabic-text"> مكان عشوائي </span>
            <i className="fa fa-random"></i>
          </button>
        </Grid>

        <Grid className="random-places"
              width={220}
              gap={12}>
          {this.props.videos.map(video =>
            <VideoItem id={video.id} key={video.id} title={video.title}/>
          )}
        </Grid>
        <RandomItemTitle title={this.props.placeName}
                         count={this.props.placeCount}
                         src={'/results/place/' + this.props.placeName}
        />
      </section>

    )
  }
}

RandomPlace.propTypes = {
  placeName: PropTypes.string,
  allPlaces: PropTypes.array,
  videos: PropTypes.array,
  loading: PropTypes.bool,
  placeCount: PropTypes.number,
  getRandomPlaceVideos: PropTypes.func
};

export default (RandomPlace);