2020-06-15 22:33:03 +02:00
|
|
|
import REWARDS from 'rewards';
|
2018-09-26 02:12:07 +02:00
|
|
|
import { connect } from 'react-redux';
|
2018-10-29 18:23:53 +01:00
|
|
|
import { doHideModal } from 'redux/actions/app';
|
2020-06-15 22:33:03 +02:00
|
|
|
import { doClaimRewardType } from 'redux/actions/rewards';
|
|
|
|
import { makeSelectClaimRewardError, makeSelectIsRewardClaimPending } from 'redux/selectors/rewards';
|
|
|
|
|
2018-09-26 02:12:07 +02:00
|
|
|
import ModalRewardCode from './view';
|
|
|
|
|
2019-03-18 06:09:50 +01:00
|
|
|
const select = state => ({
|
2018-09-26 02:12:07 +02:00
|
|
|
rewardIsPending: makeSelectIsRewardClaimPending()(state, {
|
2020-06-15 22:33:03 +02:00
|
|
|
reward_type: REWARDS.TYPE_REWARD_CODE,
|
2018-09-26 02:12:07 +02:00
|
|
|
}),
|
2020-06-15 22:33:03 +02:00
|
|
|
error: makeSelectClaimRewardError()(state, { reward_type: REWARDS.TYPE_REWARD_CODE }),
|
2018-09-26 02:12:07 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
const perform = dispatch => ({
|
2018-10-29 18:23:53 +01:00
|
|
|
closeModal: () => dispatch(doHideModal()),
|
2020-06-15 22:33:03 +02:00
|
|
|
submitRewardCode: code => dispatch(doClaimRewardType(REWARDS.TYPE_REWARD_CODE, { params: { code } })),
|
2018-09-26 02:12:07 +02:00
|
|
|
});
|
|
|
|
|
2020-06-15 22:33:03 +02:00
|
|
|
export default connect(select, perform)(ModalRewardCode);
|