add state, dispatch and action

This commit is contained in:
nicocappabianca
2020-09-14 15:15:37 -03:00
parent a95d9dfb71
commit 80b9229469
2 changed files with 13 additions and 4 deletions
+4 -3
View File
@@ -9,8 +9,8 @@ const AdminLTE =
// Maps the props that are going to be sended
// to the component connected with Redux
const mapStateToProps = ({ walletInfo, bchBalance, bchWallet }) => {
return { walletInfo, bchBalance, bchWallet }
const mapStateToProps = ({ walletInfo, bchBalance, bchWallet, tokensInfo }) => {
return { walletInfo, bchBalance, bchWallet, tokensInfo }
}
// Send each action of the reducer as props
@@ -19,7 +19,8 @@ const mapDispatchToProps = dispatch => {
return {
setWalletInfo: value => dispatch({ type: 'SET_WALLET_INFO', value }),
updateBalance: value => dispatch({ type: 'UPDATE_BALANCE', value }),
setBchWallet: value => dispatch({ type: 'SET_BCH_WALLET', value })
setBchWallet: value => dispatch({ type: 'SET_BCH_WALLET', value }),
setTokensInfo: value => dispatch({ type: 'SET_TOKENS_INFO', value })
}
}
+9 -1
View File
@@ -47,6 +47,13 @@ const reducer = (state, action) => {
})
}
// Get or update tokens information
if (action.type === 'SET_TOKENS_INFO') {
return Object.assign({}, state, {
tokensInfo: action.value
})
}
return state
}
@@ -85,7 +92,8 @@ const instanceWallet = () => {
const initialState = {
walletInfo: localStorageInfo, // Object wallet info
bchBalance: { bchBalance: 0, usdBalance: 0 }, // Wallet Balance
bchWallet: instanceWallet() // minimal-slp-wallet instance
bchWallet: instanceWallet(), // minimal-slp-wallet instance
tokensInfo: []
}
const createStore = () => reduxCreateStore(reducer, initialState)