jsonFields: ['tags']
})
+const switchAccount = (accountAlias) => {
+ return (dispatch) => {
+ dispatch({type: 'SET_CURRENT_ACCOUNT', account: accountAlias})
+ }
+}
+
let actions = {
...list,
...create,
},
listAddresses: (accountId) => {
return chainClient().accounts.listAddresses({accountId})
- }
+ },
+ switchAccount
}
export default actions
import { BaseList, TableList } from 'features/shared/components'
-
import ListItem from './ListItem'
import {withNamespaces} from 'react-i18next'
+import React from 'react'
+import { actions } from 'features/accounts'
const type = 'account'
+class List extends React.Component {
+
+ render() {
+ const ItemList = BaseList.ItemList
+ const items = this.props.items
+ items.map(item =>{
+ if(item.alias === this.props.currentAccount){
+ item.isUsed = true
+ }else {
+ item.isUsed= false
+ }
+ })
+ return (<ItemList {...this.props} items = {items}/>)
+ }
+}
const mapStateToProps = (state, ownProps) => {
return {
+ currentAccount: state.account.currentAccount,
...BaseList.mapStateToProps(type, ListItem, {
wrapperComponent: TableList,
wrapperProps: {
})(state)
}
}
+
+const mapDispatchToProps = (dispatch) => ({
+ ...BaseList.mapDispatchToProps(type)(dispatch),
+ itemActions: {
+ switch: (account) => {
+ dispatch(actions.switchAccount(account))
+ }
+ },
+})
export default withNamespaces('translations') (BaseList.connect(
mapStateToProps,
- BaseList.mapDispatchToProps(type)
+ mapDispatchToProps,
+ (List)
))
return(
<tr>
- <td>{item.alias || '-'}</td>
- <td><code>{item.id}</code></td>
<td>
<Link to={`/accounts/${item.id}`}>
- {t('commonWords.viewDetails')} →
+ {item.alias || '-'}
</Link>
</td>
+ <td><code>{item.id}</code></td>
+ <td>
+ {item.isUsed?
+ <button className='btn btn-default btn-sx' disabled>
+ inused
+ </button>:
+ <button className='btn btn-primary btn-xs' onClick={() => this.props.switch(item.alias)}>
+ switch
+ </button>
+ }
+ </td>
</tr>
)
}
const unconfirmed = store.getState().transaction.unconfirm
const pageNumber = parseInt(state.location.query.page || 1)
const pageSizes = (type === 'unspent')? UTXOpageSize: pageSize
+ let options = {pageSize: pageSizes}
if (pageNumber == 1) {
- store.dispatch(actions[type].fetchPage(query, pageNumber, { refresh: true, pageSize: pageSizes , accountAlias , unconfirmed:true }))
+ options = type==='transaction'? {...options,refresh: true, accountAlias , unconfirmed:true }: options
+ store.dispatch(actions[type].fetchPage(query, pageNumber, options))
} else {
- store.dispatch(actions[type].fetchPage(query, pageNumber, { pageSize: pageSizes , accountAlias , unconfirmed } ))
+ options = type==='transaction'? {...options, accountAlias , unconfirmed }: options
+ store.dispatch(actions[type].fetchPage(query, pageNumber, options ))
}
}else if(type === 'balance'){
store.dispatch(actions[type].fetchAll({accountAlias}))