lbry-desktop/ui/js/modal/modalCreditIntro/index.js

42 lines
1.2 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,
2017-07-28 03:13:12 +02:00
selectTotalRewardValue,
2017-06-08 23:15:34 +02:00
} from "selectors/rewards";
import * as settings from "constants/settings";
import ModalCreditIntro 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-07-28 03:13:12 +02:00
totalRewardValue: selectTotalRewardValue(state),
2017-06-08 02:56:52 +02:00
};
};
2017-07-15 20:44:50 +02:00
const perform = dispatch => () => {
const closeModal = () => {
dispatch(doSetClientSetting(settings.CREDIT_INTRO_ACKNOWLEDGED, true));
2017-07-15 20:44:50 +02:00
dispatch(doCloseModal());
};
return {
verifyAccount: () => {
closeModal();
2017-07-28 03:13:12 +02:00
dispatch(doAuthNavigate("/discover"));
2017-07-15 20:44:50 +02:00
},
closeModal: closeModal,
};
};
2017-06-08 02:56:52 +02:00
export default connect(select, perform)(ModalCreditIntro);