{"size": 1713, "ext": "js", "max_stars_repo_path": "imports/components/gols.js", "max_stars_repo_name": "nvasquez97/ElGol", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "imports/components/gols.js", "max_issues_repo_name": "nvasquez97/ElGol", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "imports/components/gols.js", "max_forks_repo_name": "nvasquez97/ElGol", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.8260869565, "max_line_length": 204, "alphanum_fraction": 0.6170461179}
import React, { Component } from 'react';
import { Usuarios } from '../api/usuarios.js';
import Youtube from 'youtube-api-search';
const API_K="AIzaSyD5gVIxzt4WtEBhoLVgSBgwUkcMMs-FGD0";

export default class Gol extends Component{
	constructor(props)
	{
		super(props);
		this.state={
			gols:[],
			ver:false,
			videoId:'',
		}
	}
	search()
	{
		Youtube({key:API_K, term: "gol "+this.props.gol.jugador+" "+this.props.gol.gol+" vs "+this.props.gol.vs, channelId:'UCqoAj1bv79eZJc326cemDnw'}, (videos)=>
		{	
			this.setState({
				gols:videos,
				videoId:videos[0].id.videoId,
			});	

		});
	}
	verVideo()
	{		
		let verN = !this.state.ver;
		this.setState({
			ver:verN,
		});
	}
	getURL(){
		let url="https://www.youtube.com/embed/"+this.state.videoId+"?autoplay=1";
		return url;
	}
	render()
	{
		if(this.state.gols.length<1)
		{
			this.search();
		}
		return(
			<div>

			{this.props.nombre===this.props.gol.jugador?
			<div>
			<div className="row gris" title="Mira el video" onClick={this.verVideo.bind(this)}>
			<hr></hr>
			{this.props.gol.orden===31?<h5 className="tEquipo"><span><i className="fa fa-video-camera" aria-hidden="true"></i> <strong> Merjor gol:</strong></span> {this.props.gol.gol} vs {this.props.gol.vs} </h5>
				:<h5 className="tEquipo"><span><i className="fa fa-video-camera" aria-hidden="true"></i></span> {this.props.gol.gol} vs {this.props.gol.vs} 
				</h5>
			}
			</div>
			<hr></hr>
			</div>
			:<span></span>
			}
			{this.state.ver && this.state.videoId!==''?
				<div  className="embed-responsive embed-responsive-16by9">
            		<iframe className="embed-responsive-item" src={this.getURL()} ></iframe>
          		</div>
				:<span></span>}
			
			</div>);
	}

}