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

39 lines
1 KiB
JavaScript
Raw Normal View History

2017-06-08 02:56:52 +02:00
import React from "react";
2017-06-08 23:15:34 +02:00
import rewards from "rewards";
2017-06-08 02:56:52 +02:00
import { connect } from "react-redux";
import { doCloseModal, doAuthNavigate } from "actions/app";
2017-07-15 20:44:50 +02:00
import { doSetClientSetting } from "actions/settings";
2017-06-08 02:56:52 +02:00
import { selectUserIsRewardApproved } from "selectors/user";
2017-06-08 23:15:34 +02:00
import {
makeSelectHasClaimedReward,
makeSelectRewardByType,
} from "selectors/rewards";
2017-07-10 19:19:42 +02:00
import ModalWelcome from "./view";
2017-06-08 02:56:52 +02:00
const select = (state, props) => {
2017-06-08 23:15:34 +02:00
const selectHasClaimed = makeSelectHasClaimedReward(),
selectReward = makeSelectRewardByType();
2017-06-08 02:56:52 +02:00
return {
isRewardApproved: selectUserIsRewardApproved(state),
2017-06-08 23:15:34 +02:00
reward: selectReward(state, { reward_type: rewards.TYPE_NEW_USER }),
2017-06-08 02:56:52 +02:00
};
};
2017-07-15 20:44:50 +02:00
const perform = dispatch => () => {
const closeModal = () => {
dispatch(doSetClientSetting("welcome_acknowledged", true));
dispatch(doCloseModal());
};
return {
verifyAccount: () => {
closeModal();
dispatch(doAuthNavigate("/rewards"));
2017-07-15 20:44:50 +02:00
},
closeModal: closeModal,
};
};
2017-06-08 02:56:52 +02:00
2017-07-10 19:19:42 +02:00
export default connect(select, perform)(ModalWelcome);