lbry-desktop/ui/component/header/index.js

31 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

import { connect } from 'react-redux';
import { doClearEmailEntry, doClearPasswordEntry } from 'redux/actions/user';
import { doSignOut } from 'redux/actions/app';
import { formatCredits } from 'util/format-credits';
import { selectClientSetting } from 'redux/selectors/settings';
2020-10-02 17:03:25 +02:00
import { selectGetSyncErrorMessage } from 'redux/selectors/sync';
import { selectHasNavigated } from 'redux/selectors/app';
import { selectTotalBalance, selectBalance } from 'redux/selectors/wallet';
import { selectEmailToVerify, selectUser } from 'redux/selectors/user';
import * as SETTINGS from 'constants/settings';
2019-06-17 22:32:38 +02:00
import Header from './view';
2017-04-22 15:17:01 +02:00
const select = (state) => ({
balance: selectBalance(state),
emailToVerify: selectEmailToVerify(state),
hasNavigated: selectHasNavigated(state),
hideBalance: selectClientSetting(state, SETTINGS.HIDE_BALANCE),
roundedBalance: formatCredits(selectTotalBalance(state), 2, true),
roundedSpendableBalance: formatCredits(selectBalance(state), 2, true),
syncError: selectGetSyncErrorMessage(state),
2020-09-29 22:15:35 +02:00
user: selectUser(state),
2017-06-06 06:21:55 +02:00
});
2017-04-22 15:17:01 +02:00
const perform = (dispatch) => ({
clearEmailEntry: () => dispatch(doClearEmailEntry()),
clearPasswordEntry: () => dispatch(doClearPasswordEntry()),
signOut: () => dispatch(doSignOut()),
2017-06-06 06:21:55 +02:00
});
2017-04-22 15:17:01 +02:00
export default connect(select, perform)(Header);