Skip to content

Code review#8

Open
matiasgarcia91 wants to merge 64 commits into
reviewfrom
master
Open

Code review#8
matiasgarcia91 wants to merge 64 commits into
reviewfrom
master

Conversation

@matiasgarcia91

Copy link
Copy Markdown

No description provided.

NicoleKuong and others added 30 commits March 4, 2020 14:06

@matiasgarcia91 matiasgarcia91 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Looking good Nicole! Left a few comments

Comment thread src/App.js Outdated
Make an offer
</Nav.Link>
</Nav.Item>
</Nav> */}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

remove this commented out nav bar

@NicoleKuong NicoleKuong Mar 23, 2020

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Removed, thanks

Comment thread src/actions/email.js Outdated

export const NEW_EMAIL = "NEW_EMAIL";

const databaseUrl = "http://localhost:4000";

@matiasgarcia91 matiasgarcia91 Mar 12, 2020

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Get this out to some other constant file so you don't have it repeated all around. another solution for this (but using axios) is doing this in an axios.js file:

import axios from "axios";

const instance = axios.create({
  baseURL: "http://localhost:4000"
});
export default instance;

And then you import axios from this file when you make requests and it's already set

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

created a constants.js file

Comment thread src/actions/email.js
// console.log("*****", emailData, ownerEmail);
// console.log("email getState", getState().user);
const token = getState().user.token;
const data = { ...emailData, ownerEmail };

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

nice

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

thank you :)

Comment thread src/actions/item.js Outdated
const state = getState();
const { items } = state;

if (!items.length) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

cant' you check for this before even calling this function? I like that you are preventing over fetching. If not then I like to write this things in the early-return style

export const getItems = () => (dispatch, getState) => {
  const state = getState();
  const { items } = state;
  if (items.length) return;
 // then do request if there are no items
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I used the early-return style, thank you!

Comment thread src/actions/user.js Outdated
telephoneNumber,
latitude,
longitude,
history

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

when passing so many params to a function it's recommendable to pass them as an object or named arguments, for two reasons:

export const signUp = ({ username, email, password, firstName, ... })

which you call later like signUp({ username, email, password, ... })

  1. The order in which you pass them doesn't matter => less chance of mistakes
  2. It allows you to also call the function like signUp(user) where the user is an object with all this things making your code way shorter and cleaner

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

great advice, thank you!

Comment thread src/components/Login/LoginContainer.js Outdated
import React, { Component } from "react";
import LoginForm from "./LoginForm";
import { login } from "../../actions/user";
import { connect } from "react-redux";

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Same as in the backend we have an order for the imports:

  1. Libraries/modules
  2. my files (components, actions)
  3. css files

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

thank you for the correction!

this.state.telephoneNumber,
this.state.latitude,
this.state.longitude,
this.props.history

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

if you switch it to named arguments like I commented above you can do this.props.dispatch(signUp(this.props.state)) 😄

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

changed it and much cleaner 😄

alert("An unknown error occurred.");
break;
default:
alert("An unknown error occurred.");

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

nice, take a look at bootstrap's or material-ui's Snackbar component, it's a nice alert/message popup

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

thank you for the css advice, I will check them out

Comment thread src/reducer/email.js Outdated

export default (state = initialState, action = {}) => {
switch (action.type) {
case NEW_ITEM: {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

you are importing NEW_EMAIL but using NEW_ITEM careful

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Oh..thank you for pointing it out, I will be careful

Comment thread src/reducer/user.js Outdated
houseNumber: action.payload.houseNumber,
city: action.payload.city,
latitude: action.payload.latitude,
longitude: action.payload.longitude

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

return {..state, ..action.payload }

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This is great, thank you 😄

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