-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathStore.js
More file actions
58 lines (47 loc) · 1.43 KB
/
Store.js
File metadata and controls
58 lines (47 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import React from 'react'
import { Link } from 'react-router'
import { connect } from 'react-redux'
import Loading from '../Common/Components/Loading'
import CartContainer from '../Cart/Containers/CartContainer'
import StoreItem from './StoreItem'
import {get_products} from '../utils/redux_loader'
import {changePageTitle} from '../Layout/Actions/LayoutActions';
class Store extends React.Component {
componentWillMount() {
var oproducts = this.props.products.toJS()
if (oproducts.products.length == 0) {
get_products(this.props.dispatch)
}
const {dispatch} = this.props;
const {title} = Store.getPageMeta();
dispatch(changePageTitle(title));
}
static getPageMeta() {
return {
title: `Store | Data Skeptic`
}
}
render() {
var oproducts = this.props.products.toJS()
var products_loaded = oproducts.products_loaded
if (products_loaded == undefined) {
products_loaded = 0
}
if (products_loaded == 0) {
return <div><Loading /></div>
} else {
var products = oproducts.products
return (
<div className="center">
<div className="store-items">
{products.map(function(product) {
return <StoreItem key={product.id} product={product} />
})}
</div>
<CartContainer needCheckout={true} updatable={true} />
</div>
)
}
}
}
export default connect(state => ({ products: state.products, cart: state.cart }))(Store)