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