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

41 lines
2 KiB
JavaScript
Raw Normal View History

import * as SETTINGS from 'constants/settings';
import { connect } from 'react-redux';
import { selectTotalBalance, selectBalance } from 'redux/selectors/wallet';
import { formatCredits } from 'util/format-credits';
2020-10-02 11:03:25 -04:00
import { selectGetSyncErrorMessage } from 'redux/selectors/sync';
2020-09-29 16:15:35 -04:00
import { selectUserVerifiedEmail, selectUserEmail, selectEmailToVerify, selectUser } from 'redux/selectors/user';
import { doClearEmailEntry, doClearPasswordEntry } from 'redux/actions/user';
2020-09-04 11:02:30 -04:00
import { doSetClientSetting } from 'redux/actions/settings';
2019-12-18 00:27:08 -05:00
import { doSignOut, doOpenModal } from 'redux/actions/app';
import { selectClientSetting, selectLanguage } from 'redux/selectors/settings';
import { selectHasNavigated, selectActiveChannelClaim, selectActiveChannelStakedLevel } from 'redux/selectors/app';
2019-06-17 16:32:38 -04:00
import Header from './view';
2017-04-22 20:17:01 +07:00
const select = (state) => ({
language: selectLanguage(state),
balance: selectBalance(state),
roundedSpendableBalance: formatCredits(selectBalance(state), 2, true),
roundedBalance: formatCredits(selectTotalBalance(state), 2, true),
currentTheme: selectClientSetting(state, SETTINGS.THEME),
automaticDarkModeEnabled: selectClientSetting(state, SETTINGS.AUTOMATIC_DARK_MODE_ENABLED),
hideBalance: selectClientSetting(state, SETTINGS.HIDE_BALANCE),
authenticated: selectUserVerifiedEmail(state),
email: selectUserEmail(state),
syncError: selectGetSyncErrorMessage(state),
emailToVerify: selectEmailToVerify(state),
hasNavigated: selectHasNavigated(state),
2020-09-29 16:15:35 -04:00
user: selectUser(state),
activeChannelClaim: selectActiveChannelClaim(state),
activeChannelStakedLevel: selectActiveChannelStakedLevel(state),
2017-06-05 21:21:55 -07:00
});
2017-04-22 20:17:01 +07:00
const perform = (dispatch) => ({
2020-09-04 11:02:30 -04:00
setClientSetting: (key, value, push) => dispatch(doSetClientSetting(key, value, push)),
2019-09-26 12:07:11 -04:00
signOut: () => dispatch(doSignOut()),
2021-12-13 16:17:30 +08:00
doOpenModal: (modal, props) => dispatch(doOpenModal(modal, props)),
clearEmailEntry: () => dispatch(doClearEmailEntry()),
clearPasswordEntry: () => dispatch(doClearPasswordEntry()),
2017-06-05 21:21:55 -07:00
});
2017-04-22 20:17:01 +07:00
export default connect(select, perform)(Header);