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

34 lines
1.5 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import { doClearEmailEntry, doClearPasswordEntry } from 'redux/actions/user';
2019-12-18 06:27:08 +01:00
import { doSignOut, doOpenModal } from 'redux/actions/app';
import { formatCredits } from 'util/format-credits';
import { selectClientSetting } from 'redux/selectors/settings';
import { selectGetSyncErrorMessage } from 'redux/selectors/sync';
import { selectHasNavigated } from 'redux/selectors/app';
import { selectTotalBalance, selectBalance } from 'redux/selectors/wallet';
import { selectUserVerifiedEmail, selectEmailToVerify, selectUser } from 'redux/selectors/user';
import * as MODALS from 'constants/modal_types';
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) => ({
authenticated: selectUserVerifiedEmail(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()),
openChangelog: (modalProps) => dispatch(doOpenModal(MODALS.CONFIRM, modalProps)),
2017-06-06 06:21:55 +02:00
});
2017-04-22 15:17:01 +02:00
export default connect(select, perform)(Header);