OSDN Git Service

add the peer information page.
[bytom/bytom-dashboard.git] / src / features / peers / actions.js
1 import { baseListActions } from 'features/shared/actions'
2 import { chainClient } from 'utility/environment'
3 import {push} from 'react-router-redux'
4
5 const disconnect = (id) => {
6   return (dispatch) => {
7     return chainClient().peers.disconnect({peer_id: id})
8       .then((resp) => {
9         if(resp.status == 'fail'){
10           dispatch({type: 'ERROR', payload: { 'message': resp.msg}})
11         }else{
12           dispatch(push({
13             pathname: '/peers',
14             state: {
15               preserveFlash: true
16             }
17           }))
18         }
19       })
20       .catch((err) => {
21         if (!err.status) {
22           dispatch({type: 'ERROR', payload: { 'message': err}})
23         }
24       })
25   }
26 }
27
28 let actions = {
29   disconnect,
30   ...baseListActions('peer')
31 }
32
33 export default actions