Skip to content

giphy project#75

Open
oscarGrandeG wants to merge 37 commits into
wizelineacademy:masterfrom
oscarGrandeG:master
Open

giphy project#75
oscarGrandeG wants to merge 37 commits into
wizelineacademy:masterfrom
oscarGrandeG:master

Conversation

@oscarGrandeG

Copy link
Copy Markdown

No description provided.

Comment thread src/components/Gifs/Gifs.js Outdated
// UI
import UI from './Gifs.ui';

class Search extends Component {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm not sure why are you using two components to map one container. You could just use one component and one container.


import UI from './Search.ui';

class Search extends Component {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same thing, why are you using two components and one container? I still believe that you could just use one :).

// UI
import UI from './SearchResult.ui';

class SearchResult extends Component {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same comment

Comment thread src/reducer/favorites.js Outdated
const { add } = action;
const favoriteList = [...newState, add];

localStorage.setItem('favorites', JSON.stringify(favoriteList));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this are side effects and should be done by a sagas rather than a reducer.

Comment thread src/reducer/favorites.js Outdated
...state.slice(i + 1)
];

localStorage.setItem('favorites', JSON.stringify(deleteFavorite));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

same here

Comment thread src/reducer/index.js
import gif from './getAllTrendingGifs';
import searchGif from './searchGif';
import favorites from './favorites';
// import GifFilter from './GifFilter';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

delete unused code

export function* watchGetAllTrendingGif() {
try {
const options = {
url: 'http://api.giphy.com/v1/gifs/trending?limit=25&offset=50&rating=g&api_key=8lCcODDfELugUIKA3mCMdGbp1UBdtx15&lang=es'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

use a .env for api keys, for security

Comment thread src/sagas/searchGif.js
export function* searchGifs(res) {
try {
const options = {
url: `http://api.giphy.com/v1/gifs/search?q=${res.result}&api_key=8lCcODDfELugUIKA3mCMdGbp1UBdtx15&limit=5&lang=es`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

same comment

Comment thread src/index.js
@@ -2,7 +2,5 @@ import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

use injectGlobal

Comment thread src/App.js
import { Provider } from 'react-redux';
import { BrowserRouter as Router, Route, Switch, Redirect } from 'react-router-dom';

import './App.css';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

use styled-components please

Comment thread src/App.js
</div>
<Provider store={store}>
<Router>
<Switch>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread src/App.js
<Router>
<Switch>
<Route exact path="/" component={Gifs} />
<Route exact path="/search/:q" component={SearchResult} />

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread src/App.js
<Route exact path="/search/:q" component={SearchResult} />
<Route path="/favorites" component={Favorites} />
<Route path="*" component={NotFound} />
<Redirect to="not-found"/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This redirect wont get called

<div>
<h5>Pagina no encontrada.</h5>
<div>
<Link to="/">Regresar a inicio.</Link>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

@Robfz Robfz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some general feedback, looks good so far. Also, consider adding new lines at the end of files.

Comment thread src/actions/index.js
export const DELETE_FAVORITES = 'DELETE_FAVORITES';
export const FILTER_FAVORITES = 'FILTER_FAVORITES';

function action(type, payload = {}) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Really liked your approach to the payload definition, and the fact that you are giving a default value to it. I also like the way you are wrapping the payload inside an object 👍

export default connect(mapStateToProps, {
deleteFav,
getFavorites,
filterFavorites,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

// actions
import { add, getFavorites, deleteFav } from "./../../actions";

class Gifs extends Component {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this could be a functional component.

import Search from './../Search/Search';
import Menu from './../Sidebar/Sidebar';

class SearchResult extends Component {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This component could also be a functional one.

Comment thread src/reducer/GifFilter.js
const gif = (state = {}, action) => {
switch (action.type) {
case actions.FILTER_FAVORITES:
const newObj = { ...action }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Try to give some meaningful names to variables. This could be named newState.

Comment thread src/reducer/favorites.js Outdated
@@ -0,0 +1,22 @@
import * as actions from "../actions";
const favorite = {
add: [],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is this?

Comment thread src/reducer/searchGif.js
switch (action.type) {
case actions.SEARCH_RESULT:
return action.result;
case actions.SEARCH_EVENT:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can write these cases like:

case actions.SEARCH_RESULT:
case actions.SEARCH_EVENT:
  return action.result;

Comment thread src/sagas/favorites.js
import * as actions from '../actions';

export function* watchFavorites() {
const storage = JSON.parse(localStorage.getItem('favorites'));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great! These side effects are perfectly encapsulated in Sagas.

Comment thread src/sagas/searchGif.js
const resultSearch = yield call(ajax, options);
yield put(actions.searchResult(resultSearch));
} catch (error) {
yield put({ type: actions.GET_TRENDING_GIF_FAILED, error });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use an action creator here.

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.

5 participants