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 { selectBalance } from 'lbry-redux';
|
||||
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
||||
import { doClaimRewardType } from 'redux/actions/rewards';
|
||||
import ChannelNew from './view';
|
||||
|
||||
const select = (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 = {
|
||||
balance: number,
|
||||
claimConfirmEmailReward: () => void,
|
||||
isAuthenticated: boolean,
|
||||
};
|
||||
|
||||
function ChannelNew(props: Props) {
|
||||
const { balance } = props;
|
||||
const { balance, claimConfirmEmailReward, isAuthenticated } = props;
|
||||
const { push, location } = useHistory();
|
||||
const urlSearchParams = new URLSearchParams(location.search);
|
||||
const redirectUrl = urlSearchParams.get('redirect');
|
||||
const emptyBalance = balance === 0;
|
||||
|
||||
React.useEffect(() => {
|
||||
if (isAuthenticated && emptyBalance) {
|
||||
claimConfirmEmailReward();
|
||||
}
|
||||
}, [isAuthenticated, claimConfirmEmailReward, emptyBalance]);
|
||||
|
||||
return (
|
||||
<Page noSideNavigation noFooter backout={{ title: __('Create a channel'), backLabel: __('Cancel') }}>
|
||||
{emptyBalance && <YrblWalletEmpty />}
|
||||
|
|
Loading…
Reference in a new issue