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

The movie db #4

Merged
merged 6 commits into from
Mar 14, 2019
Merged

The movie db #4

merged 6 commits into from
Mar 14, 2019

Conversation

Saturday17
Copy link
Owner

Adding themoviedb to the project and implementation of search

package.json Outdated
@@ -4,7 +4,10 @@
"private": true,
"dependencies": {
"inspector": "^0.5.0",
"jquery": "^3.3.1",
"lodash.uniqueid": "^4.0.1",
Copy link
Collaborator

Choose a reason for hiding this comment

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

install full version of lodash

</div>
);
import $ from 'jquery';
import uniqueId from 'lodash.uniqueid';
Copy link
Collaborator

Choose a reason for hiding this comment

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

After installation full version of lodash write:

import uniqueId from 'lodash/uniqueId';

super(props);
this.state = {}

this.performSearch('avengers');
Copy link
Collaborator

Choose a reason for hiding this comment

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

move it in componentDidMount. For more info read:
https://daveceddia.com/ajax-requests-in-react/,
reactjs/react.dev#302


constructor(props) {
super(props);
this.state = {}
Copy link
Collaborator

@siarhei-arzamasau siarhei-arzamasau Mar 14, 2019

Choose a reason for hiding this comment

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

If you just initialize state, then you don't need the constructor. Move state = {} outside of constructor and remove constructor at all. Before removing constructor read next comment. Read: https://www.robinwieruch.de/react-state-without-constructor/

performSearch(searchWord) {
console.log('Perform search using moviedb');
const urlString = 'https://api.themoviedb.org/3/search/movie?api_key=0db50d1e81184cc04e761a3e55b0ee62&query=' + searchWord;
$.ajax({
Copy link
Collaborator

Choose a reason for hiding this comment

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

Usage of jquery only for ajax request is redundant. You install big library and use only one feature from it. Instead of jquery look at axios(https://github.com/axios/axios) or use native fetch(https://scotch.io/tutorials/how-to-use-the-javascript-fetch-api-to-get-data) api. Axios is preferably.

@Saturday17 Saturday17 merged commit 70bf209 into master Mar 14, 2019
@Saturday17 Saturday17 deleted the TheMovieDB branch March 14, 2019 12:27
movieRows.push(movieRow);
})
this.setState({
rows: movieRows
Copy link
Collaborator

Choose a reason for hiding this comment

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

movieRows: movieRows


searchChangeHandler = e => {
const searchWord = e.target.value;
this.performSearch(searchWord)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Right now when the user enters one letter your app makes the request. For word 'hero' your app will make 4 requests. Look at lodash debounce to fix multiple requests issue.

<h4>{ time }<sub>minutes</sub></h4>
<p>{ description }</p>
<div className="price-tag" key={movie.id}>
<img src={ movie.poster_src } alt="poster"/>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better to use movie name and word poster for alt attribute. example: 'Superman poster'

<h4>{ time }<sub>minutes</sub></h4>
<p>{ description }</p>
<div className="price-tag" key={movie.id}>
<img src={ movie.poster_src } alt="poster"/>
Copy link
Collaborator

Choose a reason for hiding this comment

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

destructure movie properties.

@@ -29,4 +30,8 @@ class Authorization extends Component {
}
}

Authorization.propTypes = {
onTriggerModal: PropTypes.func
Copy link
Collaborator

Choose a reason for hiding this comment

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

should be isRequired:

onTriggerModal: PropTypes.func.isRequired

Copy link
Collaborator

Choose a reason for hiding this comment

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

Check other places where you use PropTypes. If the property is required then add isRequired.

<li><a href="#" className="footer-menu-link">Food and Drinks</a></li>
<li><a href="#" className="footer-menu-link">Info</a></li>
<li><a href="#" className="footer-sign-in sign-in-btn footer-menu-link" onClick={ onHandleTriggerModal }>Sign in</a></li>
<li><Link to="/" className="footer-top__menu__link">Home</Link></li>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wrong BEM naming. Read https://css-tricks.com/bem-101/

</ul>
);
}
}

FooterNavigation.propTypes = {
onHandleTriggerModal: PropTypes.func
Copy link
Collaborator

Choose a reason for hiding this comment

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

isRequired


return (
<>
{ isOpenMiniMenu && <MiniMenu onHandleTriggerModal={ onHandleTriggerModal } handleRemoveMiniMenu={ this.handleRemoveMiniMenu } onAnimatedClass={ animatedClass } handleTriggerSearch={ this.handleTriggerSearch } isOpenSearchInput={ isOpenSearchInput } /> }
{ isOpenMiniMenu && <MiniMenu onHandleTriggerModal={ onHandleTriggerModal } handleRemoveMiniMenu={ this.handleRemoveMiniMenu } handleTriggerSearch={ this.handleTriggerSearch } isOpenSearchInput={ isOpenSearchInput } /> }
Copy link
Collaborator

Choose a reason for hiding this comment

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

format to:
{ isOpenMiniMenu && ( <MiniMenu onHandleTriggerModal={ onHandleTriggerModal } handleRemoveMiniMenu={ this.handleRemoveMiniMenu } handleTriggerSearch={ this.handleTriggerSearch } isOpenSearchInput={ isOpenSearchInput } /> )}

performSearch() {
console.log('Perform search using moviedb');
const urlString = 'https://api.themoviedb.org/3/movie/popular?api_key=0db50d1e81184cc04e761a3e55b0ee62&language=en-US&page=1';
$.ajax({
Copy link
Collaborator

Choose a reason for hiding this comment

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

use axios

transition: 0.5s;
}
.price-tag:hover {
cursor: default;
box-shadow: 0px 0px 60px 10px rgba(204, 204, 223, 0.71);
}
.price-tag img {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add class for img, use classes for styling.

}
.price-tag span {
font-size: 1.4rem;
.price-tag img:hover {
Copy link
Collaborator

Choose a reason for hiding this comment

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

class

cursor: pointer;
opacity: 0.9;
}
.price-tag h2 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

class

text-transform: uppercase;
margin: 3rem auto 1rem;
margin: 0 auto;
color: #4f4f6f;
}
.price-tag h4 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

class

width: 50%;
}
.footer-menu ul {
.footer-top__menu ul {
Copy link
Collaborator

Choose a reason for hiding this comment

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

class for ul

display: flex;
justify-content: space-around;
list-style: none;
}
.footer-menu-link {
.footer-top__menu__link {
Copy link
Collaborator

Choose a reason for hiding this comment

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

incorrect BEM naming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants