Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-cinema #17

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
latest
  • Loading branch information
jay9044 committed Sep 29, 2018
commit 30bb5bd3da137e59e432a299b0866ebd0b6be09e
55 changes: 55 additions & 0 deletions src/components/Displayresults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React from 'react';

class Displayresults extends React.Component {
constructor(){
super()
this.fetchFilmInfo = this.fetchFilmInfo.bind(this)

this.state ={
info: {},
MovieInfoHeading: ''
}
}



fetchFilmInfo(){

fetch(`http://www.omdbapi.com/?apikey=8d5ab09&i=${this.props.movie.imdbID}`)
.then(response => response.json())
.then(body =>
this.setState({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to store the returned movie object in state and generate the strings to display to user in render method

info: body,
MovieInfoHeading: 'Movie Information:',
Plot: `Plot: ${body.Plot}`,
imdbRating: `Rating: ${body.imdbRating}`,
Director: `Director: ${body.Director}`,
Genre: `Genre: ${body.Genre}`,
Runtime: `Runtime: ${body.Runtime}`,


}))
}

render(){
return (

<div className='results' >
<h1 className='scroll-heading'>{this.props.movie.Title} ({this.props.movie.Year})</h1>
<span>Click For Movie Info</span>
<img onClick={this.fetchFilmInfo} className='posters' src={this.props.movie.Poster} />
<p>{this.state.Plot} </p>
<p>{this.state.imdbRating}</p>
<p>{this.state.Director}</p>
<p>{this.state.Genre}</p>
<p>{this.state.Runtime}</p>

</div>
);
}
}

export default Displayresults;



49 changes: 49 additions & 0 deletions src/components/Hero.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';


class Hero extends React.Component {
constructor(){
super();
this.fetchHero = this.fetchHero.bind(this)
this.state ={
movie: []
}
}

fetchHero(){
fetch("http://www.omdbapi.com/?apikey=8d5ab09&i=tt1270797")
.then(response => response.json())
.then(body => {(console.log(body))
this.setState({
movie: body
})
})
}

componentDidMount(){
this.fetchHero()
}



render(){
return (

<div>
<h2 className='hero-heading'>Today's Featured Film </h2>
<p className='scroll-heading'>VENOM</p>
<p className='scroll-heading'>In Theatres Soon!</p>
<h3 className='scroll-heading'>Scroll down to watch the trailer</h3>
<div className='hero-landing'>
<img onClick={this.handleClick} className='hero-image' src={this.state.movie.Poster} />
</div>
<div className='hero-video'>
<iframe width="560" height="315" src="https://www.youtube.com/embed/xLCn88bfW1o?autoplay=1" frameBorder="0" allowFullScreen></iframe>
</div>
</div>
);
}
}

export default Hero;

15 changes: 15 additions & 0 deletions src/components/Results.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import Displayresults from './Displayresults'
class Results extends React.Component {
render(){
return (
<div>
{this.props.moviesArray.map(movie => {
return <Displayresults key={movie.imdbID} movie={movie}/>
})}
</div>
);
}
}

export default Results;
38 changes: 38 additions & 0 deletions src/components/Search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';
import Displayresults from './Displayresults'
class Search extends React.Component {
constructor(){
super()
this.state = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the search query is stored both in Search and App. It would better to avoid state duplication and pass the search query down from App to Search

text: ""
}
this.handleSubmit = this.handleSubmit.bind(this)
this.handleChange = this.handleChange.bind(this)
}

handleChange(event){
this.setState({
text:event.target.value
})
}

handleSubmit(event){
//capture user input submit
event.preventDefault()
this.props.receiver(this.state.text)

}


render(){
return (

<form onSubmit={this.handleSubmit}>
<input type='text' placeholder='Search For A Movie..' onChange={this.handleChange}/>
<button type='submit'>Search..</button>
</form>
);
}
}

export default Search;