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

Done #742

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Done #742

Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"enzyme-adapter-react-16": "^1.0.1",
"fetch-mock": "^6.5.2",
"isomorphic-fetch": "^2.2.1",
"mocha-multi": "^1.0.1",
"mocha-multi": "^1.1.3",
"node-fetch": "^2.2.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
Expand Down
28 changes: 28 additions & 0 deletions src/components/LatestMovieReviewsContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,31 @@ const URL = 'https://api.nytimes.com/svc/movies/v2/reviews/all.json?'
+ `api-key=${NYT_API_KEY}`;

// Code LatestMovieReviewsContainer Here

class LatestMovieReviewsContainer extends Component {
constructor() {
super();

this.state = {
reviews: []
};
}

componentWillMount() {
fetch(URL)
.then(res => res.json())
.then(response => this.setState({ reviews: response.results }));
}

render() {
return (
<div className="latest-movie-reviews">
<h2>The Latest Reviews:</h2>
<MovieReviews reviews={this.state.reviews} />
</div>
);
}
}


export default LatestMovieReviewsContainer;
38 changes: 38 additions & 0 deletions src/components/MovieReviews.js
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
// Code MovieReviews Here

import React from 'react';

const Review = ({
headline,
byline,
link,
summary_short
}) => {
return (

<div
key={headline}
className="review"
>
<header>
<a
className="review-link"

href={link.url}
>
{headline}
</a>
<br/>
<span className="author">{byline}</span>
</header>
<blockquote>{summary_short}</blockquote>
</div>
);
};

const MovieReviews = ({ reviews }) => <div className="review-list">{reviews.map(Review)}</div>;

MovieReviews.defaultProps = {
reviews: []
};

export default MovieReviews;
48 changes: 47 additions & 1 deletion src/components/SearchableMovieReviewsContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,53 @@ import 'isomorphic-fetch';
import MovieReviews from './MovieReviews'

const NYT_API_KEY = 'dGpQ5OmGP2SgfvZimlpCUoF4iOag9qzZ';
const URL = 'https://api.nytimes.com/svc/movies/v2/reviews/search.json?'
const BASE_URL = 'https://api.nytimes.com/svc/movies/v2/reviews/search.json?'
+ `api-key=${NYT_API_KEY}`;

// Code SearchableMovieReviewsContainer Here


class SearchableMovieReviewsContainer extends Component {

constructor() {
super();

this.state = {
searchTerm: '',
reviews: []
};
}

handleSearchInputChange = event => this.setState({ searchTerm: event.target.value });

handleSubmit = event => {
event.preventDefault();

fetch(BASE_URL.concat(this.state.searchTerm))
.then(res => res.json())
.then(res => this.setState({ reviews: res.results }));
}

render() {
return (
<div className="searchable-movie-reviews">
<form onSubmit={this.handleSubmit}>
<label htmlFor='search-input'>Search Movie Reviews</label>

<input
id='search-input'
type="text"
style={{width: 300}}

onChange={this.handleSearchInputChange} />
<button type="submit">Submit</button>
</form>
{this.state.reviews.length > 0 && <h2>Movie Review By Search:</h2>}
<MovieReviews reviews={this.state.reviews} />
</div>
);
}
}


export default SearchableMovieReviewsContainer;