-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathDisplayresults.js
More file actions
62 lines (45 loc) · 1.71 KB
/
Displayresults.js
File metadata and controls
62 lines (45 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React from 'react';
class Displayresults extends React.Component {
constructor(){
super()
this.fetchFilmInfo = this.fetchFilmInfo.bind(this)
this.handleClick = this.handleClick.bind(this)
this.state ={
info: {},
MovieInfoHeading: ''
}
}
handleClick(){
}
fetchFilmInfo(){
fetch(`http://www.omdbapi.com/?apikey=8d5ab09&i=${this.props.movie.imdbID}`)
.then(response => response.json())
.then(body =>
this.setState({
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}`,
star: <i className='star-icon' class="fas fa-star"></i>
}))
}
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 className='movie-info'>{this.state.Plot} </p>
<p className='movie-info'>{this.state.imdbRating}{this.state.star}</p>
<p className='movie-info'>{this.state.Director}</p>
<p className='movie-info'>{this.state.Genre}</p>
<p className='movie-info'>{this.state.Runtime}</p>
<a onClick={this.handleClick}><i class="fas fa-heart heart-icon"><span className='add-to'>Add To Favourites</span></i></a>
</div>
);
}
}
export default Displayresults;