Ivan Asmer 4 лет назад
Родитель
Сommit
b9e2ea17fc
4 измененных файлов с 66 добавлено и 15 удалено
  1. 24 9
      package-lock.json
  2. 1 1
      package.json
  3. 29 4
      src/App.js
  4. 12 1
      src/actions/index.js

+ 24 - 9
package-lock.json

@@ -7022,7 +7022,8 @@
             },
             "ansi-regex": {
               "version": "2.1.1",
-              "bundled": true
+              "bundled": true,
+              "optional": true
             },
             "aproba": {
               "version": "1.2.0",
@@ -7059,7 +7060,8 @@
             },
             "code-point-at": {
               "version": "1.1.0",
-              "bundled": true
+              "bundled": true,
+              "optional": true
             },
             "concat-map": {
               "version": "0.0.1",
@@ -7068,7 +7070,8 @@
             },
             "console-control-strings": {
               "version": "1.1.0",
-              "bundled": true
+              "bundled": true,
+              "optional": true
             },
             "core-util-is": {
               "version": "1.0.2",
@@ -7171,7 +7174,8 @@
             },
             "inherits": {
               "version": "2.0.3",
-              "bundled": true
+              "bundled": true,
+              "optional": true
             },
             "ini": {
               "version": "1.3.5",
@@ -7181,6 +7185,7 @@
             "is-fullwidth-code-point": {
               "version": "1.0.0",
               "bundled": true,
+              "optional": true,
               "requires": {
                 "number-is-nan": "^1.0.0"
               }
@@ -7200,11 +7205,13 @@
             },
             "minimist": {
               "version": "0.0.8",
-              "bundled": true
+              "bundled": true,
+              "optional": true
             },
             "minipass": {
               "version": "2.3.5",
               "bundled": true,
+              "optional": true,
               "requires": {
                 "safe-buffer": "^5.1.2",
                 "yallist": "^3.0.0"
@@ -7221,6 +7228,7 @@
             "mkdirp": {
               "version": "0.5.1",
               "bundled": true,
+              "optional": true,
               "requires": {
                 "minimist": "0.0.8"
               }
@@ -7293,7 +7301,8 @@
             },
             "number-is-nan": {
               "version": "1.0.1",
-              "bundled": true
+              "bundled": true,
+              "optional": true
             },
             "object-assign": {
               "version": "4.1.1",
@@ -7303,6 +7312,7 @@
             "once": {
               "version": "1.4.0",
               "bundled": true,
+              "optional": true,
               "requires": {
                 "wrappy": "1"
               }
@@ -7378,7 +7388,8 @@
             },
             "safe-buffer": {
               "version": "5.1.2",
-              "bundled": true
+              "bundled": true,
+              "optional": true
             },
             "safer-buffer": {
               "version": "2.1.2",
@@ -7408,6 +7419,7 @@
             "string-width": {
               "version": "1.0.2",
               "bundled": true,
+              "optional": true,
               "requires": {
                 "code-point-at": "^1.0.0",
                 "is-fullwidth-code-point": "^1.0.0",
@@ -7425,6 +7437,7 @@
             "strip-ansi": {
               "version": "3.0.1",
               "bundled": true,
+              "optional": true,
               "requires": {
                 "ansi-regex": "^2.0.0"
               }
@@ -7463,11 +7476,13 @@
             },
             "wrappy": {
               "version": "1.0.2",
-              "bundled": true
+              "bundled": true,
+              "optional": true
             },
             "yallist": {
               "version": "3.0.3",
-              "bundled": true
+              "bundled": true,
+              "optional": true
             }
           }
         }

+ 1 - 1
package.json

@@ -34,5 +34,5 @@
       "last 1 safari version"
     ]
   },
-  "proxy": "http://localhost:5002/"
+  "proxy": "http://shop-roles.asmer.fs.a-level.com.ua/"
 }

+ 29 - 4
src/App.js

@@ -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>
     )
 }

+ 12 - 1
src/actions/index.js

@@ -35,6 +35,17 @@ export const actionPosts = () => {
 }
 
 
+export const actionCategories = () => {
+    return actionPromise('categories', gql.request(
+            `query {
+              CategoryFind(query:"[{\\"parent\\":null}]"){
+                _id name
+              }
+        }
+        `))
+}
+
+
 export const actionLogin = (login,password) => 
     async dispatch => {
         console.log(login, password)
@@ -54,7 +65,7 @@ export const actionAuthLogin = (jwt) => ({
 
 
 export const actionAuthLogout = () => {
-    history.push('/')
+//    history.push('/')
     return {
         type: "LOGOUT",
     }