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

40 lines
1.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";
2017-07-15 20:44:50 +02:00
import { doCloseModal, doNavigate } from "actions/app";
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 {
2017-06-08 23:15:34 +02:00
hasClaimed: selectHasClaimed(state, { reward_type: rewards.TYPE_NEW_USER }),
2017-06-08 02:56:52 +02:00
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();
2017-07-19 01:00:13 +02:00
dispatch(doNavigate("/auth"));
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);