-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Rhymond/responsiveFixes
Pretify code
- Loading branch information
Showing
11 changed files
with
66 additions
and
67 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
import * as types from '../constants/types'; | ||
import * as types from '../constants/types' | ||
|
||
export function getProducts() { | ||
return dispatch => { | ||
export const getProducts = () => | ||
dispatch => | ||
fetch(`products.json`) | ||
.then(response => response.json()) | ||
.then(response => { | ||
dispatch({ | ||
type: types.FETCH_PRODUCTS, | ||
payload: response.products | ||
}); | ||
}) | ||
}) | ||
} | ||
} | ||
|
||
export function compare(product) { | ||
return {type: types.COMPARE_PRODUCT, product}; | ||
} | ||
export const compare = product => ({ | ||
type: types.COMPARE_PRODUCT, | ||
product | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export const FETCH_PRODUCTS = 'FETCH_PRODUCTS'; | ||
export const COMPARE_PRODUCT = 'COMPARE_PRODUCT'; | ||
export const FETCH_PRODUCTS = 'FETCH_PRODUCTS' | ||
export const COMPARE_PRODUCT = 'COMPARE_PRODUCT' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
import React, {Component} from 'react'; | ||
import React, {Component} from 'react' | ||
import {Route, Switch} from 'react-router-dom' | ||
|
||
import {Home, NotFound} from '../'; | ||
import {Home, NotFound} from '../' | ||
|
||
export default class App extends Component { | ||
class App extends Component { | ||
render() { | ||
return ( | ||
<div className="App"> | ||
<div className="app"> | ||
<div className="container mt-4"> | ||
<Switch> | ||
<Route exact path="/" component={Home}/> | ||
<Route component={NotFound}/> | ||
</Switch> | ||
</div> | ||
</div> | ||
); | ||
) | ||
} | ||
} | ||
|
||
export default App |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,34 @@ | ||
import React from 'react'; | ||
import {bindActionCreators} from 'redux'; | ||
import {Compare, ProductList} from '../../components'; | ||
import * as productActions from '../../actions'; | ||
import {connect} from 'react-redux'; | ||
import React, {Component} from 'react' | ||
import {bindActionCreators} from 'redux' | ||
import {Compare, ProductList} from '../../components' | ||
import * as productActions from '../../actions/product' | ||
import {connect} from 'react-redux' | ||
|
||
class Home extends React.Component { | ||
class Home extends Component { | ||
componentWillMount() { | ||
this.props.actions.getProducts(); | ||
this.props.actions.getProducts() | ||
} | ||
|
||
render() { | ||
const {products, actions} = this.props; | ||
const compareProducts = products.filter(product => product.compare); | ||
const {products, actions} = this.props | ||
const compareProducts = products.filter(product => product.compare) | ||
|
||
return ( | ||
<div className="Home mt-5"> | ||
<div className="home mt-5"> | ||
<ProductList products={products} compare={actions.compare}/> | ||
{compareProducts.length >= 2 ? <Compare products={compareProducts}/> : null} | ||
{compareProducts.length >= 2 && | ||
<Compare products={compareProducts}/> | ||
} | ||
</div> | ||
); | ||
) | ||
} | ||
} | ||
|
||
function mapStateToProps(state) { | ||
return { | ||
export default connect( | ||
state => ({ | ||
products: state.product.products | ||
} | ||
} | ||
|
||
function mapDispatchToProps(dispatch) { | ||
return { | ||
}), | ||
dispatch => ({ | ||
actions: bindActionCreators(productActions, dispatch) | ||
}; | ||
} | ||
|
||
export default connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(Home); | ||
}) | ||
)(Home) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import React from 'react' | ||
import React, {Component} from 'react' | ||
|
||
export default class NotFound extends React.Component { | ||
class NotFound extends Component { | ||
render() { | ||
return ( | ||
<div> | ||
<div className="not-found"> | ||
<h1>404</h1> | ||
<h3>Page not found</h3> | ||
</div> | ||
); | ||
) | ||
} | ||
} | ||
|
||
export default NotFound |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters