mirror of
https://github.com/fullstack-cash/fullstack-gatsby-theme-bch-wallet.git
synced 2026-09-22 01:02:06 -07:00
add state, dispatch and action
This commit is contained in:
+4
-3
@@ -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 })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user