2019-12-18 00:27:08 -05:00
|
|
|
import * as MODALS from 'constants/modal_types';
|
2021-10-07 23:47:39 -04:00
|
|
|
import * as SETTINGS from 'constants/settings';
|
2017-12-21 18:08:54 -03:00
|
|
|
import { connect } from 'react-redux';
|
2021-10-07 23:47:39 -04:00
|
|
|
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';
|
2020-06-15 16:33:03 -04:00
|
|
|
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';
|
2020-11-20 08:21:31 -05:00
|
|
|
import { makeSelectClientSetting, selectLanguage } from 'redux/selectors/settings';
|
2021-10-19 00:49:51 -04:00
|
|
|
import { selectHasNavigated, selectActiveChannelClaim } from 'redux/selectors/app';
|
2019-06-17 16:32:38 -04:00
|
|
|
import Header from './view';
|
2021-12-08 17:48:02 -05:00
|
|
|
import { selectMyChannelClaims } from 'redux/selectors/claims';
|
2017-04-22 20:17:01 +07:00
|
|
|
|
2021-03-03 13:50:16 -05:00
|
|
|
const select = (state) => ({
|
2020-11-20 08:21:31 -05:00
|
|
|
language: selectLanguage(state),
|
2021-01-25 13:34:21 -05:00
|
|
|
balance: selectBalance(state),
|
|
|
|
roundedSpendableBalance: formatCredits(selectBalance(state), 2, true),
|
2021-01-12 10:25:51 -05:00
|
|
|
roundedBalance: formatCredits(selectTotalBalance(state), 2, true),
|
2019-06-17 16:32:38 -04:00
|
|
|
currentTheme: makeSelectClientSetting(SETTINGS.THEME)(state),
|
|
|
|
automaticDarkModeEnabled: makeSelectClientSetting(SETTINGS.AUTOMATIC_DARK_MODE_ENABLED)(state),
|
2019-07-29 11:37:29 -04:00
|
|
|
hideBalance: makeSelectClientSetting(SETTINGS.HIDE_BALANCE)(state),
|
2020-01-03 14:34:17 -05:00
|
|
|
authenticated: selectUserVerifiedEmail(state),
|
|
|
|
email: selectUserEmail(state),
|
2019-11-01 12:19:28 -04:00
|
|
|
syncError: selectGetSyncErrorMessage(state),
|
2020-04-13 15:16:07 -04:00
|
|
|
emailToVerify: selectEmailToVerify(state),
|
2020-07-10 17:04:36 -04:00
|
|
|
hasNavigated: selectHasNavigated(state),
|
2020-09-29 16:15:35 -04:00
|
|
|
user: selectUser(state),
|
2021-02-09 11:05:56 -05:00
|
|
|
activeChannelClaim: selectActiveChannelClaim(state),
|
2021-12-08 17:48:02 -05:00
|
|
|
myChannels: selectMyChannelClaims(state),
|
2017-06-05 21:21:55 -07:00
|
|
|
});
|
2017-04-22 20:17:01 +07:00
|
|
|
|
2021-03-03 13:50:16 -05: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()),
|
2020-03-13 19:00:22 -04:00
|
|
|
openSignOutModal: () => dispatch(doOpenModal(MODALS.SIGN_OUT)),
|
2020-04-13 15:16:07 -04:00
|
|
|
clearEmailEntry: () => dispatch(doClearEmailEntry()),
|
|
|
|
clearPasswordEntry: () => dispatch(doClearPasswordEntry()),
|
2017-06-05 21:21:55 -07:00
|
|
|
});
|
2017-04-22 20:17:01 +07:00
|
|
|
|
2020-03-13 19:00:22 -04:00
|
|
|
export default connect(select, perform)(Header);
|