|
@@ -8,7 +8,7 @@ import store from './reducers'
|
|
|
import {Router, Route, Link, Switch, Redirect} from 'react-router-dom';
|
|
|
import createHistory from "history/createBrowserHistory";
|
|
|
|
|
|
-import {actionPosts, actionLogin} from './actions'
|
|
|
+import {actionCategories, actionLogin} from './actions'
|
|
|
|
|
|
|
|
|
const history = createHistory()
|
|
@@ -47,15 +47,40 @@ const LoginForm = ({onLogin}) => {
|
|
|
const CLoginForm = connect(null, {onLogin: actionLogin})(LoginForm)
|
|
|
|
|
|
|
|
|
-store.dispatch(actionPosts())
|
|
|
+store.dispatch(actionCategories())
|
|
|
+
|
|
|
+const CategoryMenuItem = ({category:{_id, name}={_id: 'NOID', name: "NO CATEGORY"}}) =>
|
|
|
+<li>
|
|
|
+ <a href={`/category/${_id}`}>{name}</a>
|
|
|
+</li>
|
|
|
+
|
|
|
+const CategoryMenu = ({categories=
|
|
|
+[
|
|
|
+ { "_id": "5dc45acf5df9d670df48cc48", "name": "TV's" },
|
|
|
+ { "_id": "5dc49f4d5df9d670df48cc64", "name": "Airconditions" },
|
|
|
+ { "_id": "5dc458985df9d670df48cc47", "name": "Smartphones" },
|
|
|
+ ]
|
|
|
+}) =>
|
|
|
+<aside>
|
|
|
+ <ul>
|
|
|
+ {categories &&
|
|
|
+ categories.map(category => <CategoryMenuItem category={category}/>)}
|
|
|
+ </ul>
|
|
|
+</aside>
|
|
|
+
|
|
|
+const CCategoryMenu = connect(state => ({categories: state.promise.categories &&
|
|
|
+ state.promise.categories.payload &&
|
|
|
+ state.promise.categories.payload.CategoryFind}))(CategoryMenu)
|
|
|
|
|
|
export default () => {
|
|
|
return (
|
|
|
<Provider store={store}>
|
|
|
- <CLoginForm />
|
|
|
+ <CategoryMenu />
|
|
|
+ <CCategoryMenu />
|
|
|
+ { /* <CLoginForm />
|
|
|
<Router history={history}>
|
|
|
<Route path="/" component={PageMain} />
|
|
|
- </Router>
|
|
|
+ </Router> */ }
|
|
|
</Provider>
|
|
|
)
|
|
|
}
|