OSDN Git Service

fit the normal transactions into the tutorial mode.
[bytom/bytom-electron.git] / src / features / shared / routes.js
index 1c8f29f..b18aad9 100644 (file)
@@ -1,10 +1,22 @@
 import { RoutingContainer } from 'features/shared/components'
 import { humanize } from 'utility/string'
+import { UTXOpageSize, pageSize } from 'utility/environment'
 import actions from 'actions'
 
-const makeRoutes = (store, type, List, New, Show, Update, options = {}) => {
-  const loadPage = () => {
-    store.dispatch(actions[type].fetchAll())
+const makeRoutes = (store, type, List, New, Show, options = {}) => {
+  const loadPage = ( state ) => {
+    if(type === 'transaction' || type === 'unspent'){
+      const query = state.location.query
+      const pageNumber = parseInt(state.location.query.page || 1)
+      const pageSizes = (type === 'unspent')? UTXOpageSize: pageSize
+      if (pageNumber == 1) {
+        store.dispatch(actions[type].fetchPage(query, pageNumber, { refresh: true, pageSize: pageSizes }))
+      } else {
+        store.dispatch(actions[type].fetchPage(query, pageNumber,  { pageSize: pageSizes }))
+      }
+    }else{
+      store.dispatch(actions[type].fetchAll())
+    }
   }
 
   const childRoutes = []
@@ -27,13 +39,6 @@ const makeRoutes = (store, type, List, New, Show, Update, options = {}) => {
     })
   }
 
-  if (Update) {
-    childRoutes.push({
-      path: ':id/tags',
-      component: Update
-    })
-  }
-
   return {
     path: options.path || type + 's',
     component: RoutingContainer,