claim email_verified reward on channel/new page
This commit is contained in:
parent
650ce42dc0
commit
03ef30eb40
2 changed files with 21 additions and 2 deletions
|
@ -1,9 +1,20 @@
|
||||||
|
import REWARD_TYPES from 'rewards';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectBalance } from 'lbry-redux';
|
import { selectBalance } from 'lbry-redux';
|
||||||
|
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||||
|
import { doClaimRewardType } from 'redux/actions/rewards';
|
||||||
import ChannelNew from './view';
|
import ChannelNew from './view';
|
||||||
|
|
||||||
const select = (state) => ({
|
const select = (state) => ({
|
||||||
balance: selectBalance(state),
|
balance: selectBalance(state),
|
||||||
|
isAuthenticated: selectUserVerifiedEmail(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select)(ChannelNew);
|
export default connect(select, (dispatch) => ({
|
||||||
|
claimConfirmEmailReward: () =>
|
||||||
|
dispatch(
|
||||||
|
doClaimRewardType(REWARD_TYPES.TYPE_CONFIRM_EMAIL, {
|
||||||
|
notifyError: false,
|
||||||
|
})
|
||||||
|
),
|
||||||
|
}))(ChannelNew);
|
||||||
|
|
|
@ -8,15 +8,23 @@ import YrblWalletEmpty from 'component/yrblWalletEmpty';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
balance: number,
|
balance: number,
|
||||||
|
claimConfirmEmailReward: () => void,
|
||||||
|
isAuthenticated: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
function ChannelNew(props: Props) {
|
function ChannelNew(props: Props) {
|
||||||
const { balance } = props;
|
const { balance, claimConfirmEmailReward, isAuthenticated } = props;
|
||||||
const { push, location } = useHistory();
|
const { push, location } = useHistory();
|
||||||
const urlSearchParams = new URLSearchParams(location.search);
|
const urlSearchParams = new URLSearchParams(location.search);
|
||||||
const redirectUrl = urlSearchParams.get('redirect');
|
const redirectUrl = urlSearchParams.get('redirect');
|
||||||
const emptyBalance = balance === 0;
|
const emptyBalance = balance === 0;
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (isAuthenticated && emptyBalance) {
|
||||||
|
claimConfirmEmailReward();
|
||||||
|
}
|
||||||
|
}, [isAuthenticated, claimConfirmEmailReward, emptyBalance]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page noSideNavigation noFooter backout={{ title: __('Create a channel'), backLabel: __('Cancel') }}>
|
<Page noSideNavigation noFooter backout={{ title: __('Create a channel'), backLabel: __('Cancel') }}>
|
||||||
{emptyBalance && <YrblWalletEmpty />}
|
{emptyBalance && <YrblWalletEmpty />}
|
||||||
|
|
Loading…
Reference in a new issue