Fix rewards page #274
2 changed files with 79 additions and 58 deletions
|
@ -7,6 +7,7 @@ import {
|
||||||
selectUserHasEmail,
|
selectUserHasEmail,
|
||||||
selectUserIsVerificationCandidate,
|
selectUserIsVerificationCandidate,
|
||||||
} from "selectors/user";
|
} from "selectors/user";
|
||||||
|
import { doRewardList } from "actions/rewards";
|
||||||
import RewardsPage from "./view";
|
import RewardsPage from "./view";
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
|
@ -17,4 +18,8 @@ const select = state => ({
|
||||||
isVerificationCandidate: selectUserIsVerificationCandidate(state),
|
isVerificationCandidate: selectUserIsVerificationCandidate(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select, null)(RewardsPage);
|
const perform = dispatch => ({
|
||||||
|
fetchRewards: () => dispatch(doRewardList()),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(select, perform)(RewardsPage);
|
||||||
|
|
|
@ -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 {
|
const {
|
||||||
fetching,
|
fetching,
|
||||||
isEligible,
|
isEligible,
|
||||||
isVerificationCandidate,
|
isVerificationCandidate,
|
||||||
hasEmail,
|
hasEmail,
|
||||||
rewards,
|
rewards,
|
||||||
} = props;
|
} = this.props;
|
||||||
|
|
||||||
let content,
|
let content,
|
||||||
isCard = false;
|
isCard = false;
|
||||||
|
@ -87,6 +102,7 @@ const RewardsPage = props => {
|
||||||
: content}
|
: content}
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default RewardsPage;
|
export default RewardsPage;
|
||||||
|
|
Loading…
Reference in a new issue