import React from 'react' import ListPosters from '../list/posters' import ListDetails from '../list/details' class MovieButtons extends React.Component { constructor(props) { super(props); this.handleClick = this.handleClick.bind(this); } handleClick(e) { e.preventDefault(); if (this.props.fetching) { return } this.props.getMovieDetails(this.props.movie.imdb_id); } render() { const imdb_link = `http://www.imdb.com/title/${this.props.movie.imdb_id}`; return (
{this.props.fetching || Refresh } {this.props.fetching && Refreshing } {this.props.movie.polochon_url !== "" && Download } {this.props.movie.torrents && this.props.movie.torrents.map(function(torrent, index) { return ( {torrent.quality} Torrent )} )} IMDB
); } } export default class MovieList extends React.Component { componentWillMount() { if (this.props.moviesUrl) { this.props.fetchMovies(this.props.moviesUrl); } else if (this.props.params && this.props.params.search != "") { this.props.searchMovies({ key: this.props.params.search }); } } componentWillUpdate(nextProps, nextState) { if (!nextProps.params || nextProps.params.search === "") { return } if (this.props.params.search === nextProps.params.search) { return } this.props.searchMovies({ key: nextProps.params.search }); } render() { const movies = this.props.movieStore.movies; const selectedMovieId = this.props.movieStore.selectedImdbId; let index = movies.map((el) => el.imdb_id).indexOf(selectedMovieId); if (index === -1) { index = 0; } const selectedMovie = movies[index]; return (
{selectedMovie && }
); } }