Fix rewards page #274

Merged
6ea86b96 merged 2 commits from fix-rewards-page into master 2017-06-23 16:02:34 +02:00
2 changed files with 79 additions and 58 deletions
Showing only changes of commit 83f72a83b0 - Show all commits

View file

@ -7,6 +7,7 @@ import {
selectUserHasEmail,
selectUserIsVerificationCandidate,
} from "selectors/user";
import { doRewardList } from "actions/rewards";
import RewardsPage from "./view";
const select = state => ({
@ -17,4 +18,8 @@ const select = state => ({
isVerificationCandidate: selectUserIsVerificationCandidate(state),
});
export default connect(select, null)(RewardsPage);
const perform = dispatch => ({
fetchRewards: () => dispatch(doRewardList()),
});
export default connect(select, perform)(RewardsPage);

View file

@ -29,14 +29,29 @@ const RewardTile = props => {
);
};
const RewardsPage = props => {
class RewardsPage extends React.PureComponent {
componentDidMount() {
this.fetchRewards(this.props);
}
componentWillReceiveProps(nextProps) {
this.fetchRewards(nextProps);
}
fetchRewards(props) {
const { fetching, rewards, fetchRewards } = props;
if (!fetching && Object.keys(rewards).length < 1) fetchRewards();
}
render() {
const {
fetching,
isEligible,
isVerificationCandidate,
hasEmail,
rewards,
} = props;
} = this.props;
let content,
isCard = false;
@ -87,6 +102,7 @@ const RewardsPage = props => {
: content}
</main>
);
};
}
}
export default RewardsPage;