Code review#8
Conversation
Feat/select location
Feat/post item
Feat/item dashboard
Send image url to server
Feat/item details
Send owner email
Feat/searchbar by location
matiasgarcia91
left a comment
There was a problem hiding this comment.
Looking good Nicole! Left a few comments
| Make an offer | ||
| </Nav.Link> | ||
| </Nav.Item> | ||
| </Nav> */} |
There was a problem hiding this comment.
remove this commented out nav bar
|
|
||
| export const NEW_EMAIL = "NEW_EMAIL"; | ||
|
|
||
| const databaseUrl = "http://localhost:4000"; |
There was a problem hiding this comment.
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
| // console.log("*****", emailData, ownerEmail); | ||
| // console.log("email getState", getState().user); | ||
| const token = getState().user.token; | ||
| const data = { ...emailData, ownerEmail }; |
| const state = getState(); | ||
| const { items } = state; | ||
|
|
||
| if (!items.length) { |
There was a problem hiding this comment.
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
}
There was a problem hiding this comment.
I used the early-return style, thank you!
| telephoneNumber, | ||
| latitude, | ||
| longitude, | ||
| history |
There was a problem hiding this comment.
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, ... })
- The order in which you pass them doesn't matter => less chance of mistakes
- It allows you to also call the function like
signUp(user)where theuseris an object with all this things making your code way shorter and cleaner
| import React, { Component } from "react"; | ||
| import LoginForm from "./LoginForm"; | ||
| import { login } from "../../actions/user"; | ||
| import { connect } from "react-redux"; |
There was a problem hiding this comment.
Same as in the backend we have an order for the imports:
- Libraries/modules
- my files (components, actions)
- css files
There was a problem hiding this comment.
thank you for the correction!
| this.state.telephoneNumber, | ||
| this.state.latitude, | ||
| this.state.longitude, | ||
| this.props.history |
There was a problem hiding this comment.
if you switch it to named arguments like I commented above you can do this.props.dispatch(signUp(this.props.state)) 😄
There was a problem hiding this comment.
changed it and much cleaner 😄
| alert("An unknown error occurred."); | ||
| break; | ||
| default: | ||
| alert("An unknown error occurred."); |
There was a problem hiding this comment.
nice, take a look at bootstrap's or material-ui's Snackbar component, it's a nice alert/message popup
There was a problem hiding this comment.
thank you for the css advice, I will check them out
|
|
||
| export default (state = initialState, action = {}) => { | ||
| switch (action.type) { | ||
| case NEW_ITEM: { |
There was a problem hiding this comment.
you are importing NEW_EMAIL but using NEW_ITEM careful
There was a problem hiding this comment.
Oh..thank you for pointing it out, I will be careful
| houseNumber: action.payload.houseNumber, | ||
| city: action.payload.city, | ||
| latitude: action.payload.latitude, | ||
| longitude: action.payload.longitude |
There was a problem hiding this comment.
return {..state, ..action.payload }
Feat/payment page
logout function for user
No description provided.