Skip to content

Commit f6bace0

Browse files
Merge pull request #171 from fikzzzy/issue_139
Issue 139
2 parents 586bc45 + c317cd2 commit f6bace0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/containers/Challenges/index.jsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import "./styles.scss";
1414

1515
const Challenges = ({
1616
challenges,
17+
challengesMeta,
1718
search,
1819
page,
1920
perPage,
@@ -38,6 +39,16 @@ const Challenges = ({
3839
checkIsLoggedIn();
3940
}, []);
4041

42+
// reset pagination
43+
if (page > 1 && challengesMeta.total && challengesMeta.total > 0 && challenges.length === 0) {
44+
updateFilter({
45+
page: 1
46+
})
47+
updateQuery({
48+
page: 1
49+
})
50+
}
51+
4152
const BUCKET_OPEN_FOR_REGISTRATION = constants.FILTER_BUCKETS[1];
4253
const isRecommended = recommended && bucket === BUCKET_OPEN_FOR_REGISTRATION;
4354
const sortByValue = isRecommended
@@ -124,6 +135,7 @@ const mapStateToProps = (state) => ({
124135
endDateStart: state.filter.challenge.endDateStart,
125136
startDateEnd: state.filter.challenge.startDateEnd,
126137
challenges: state.challenges.challenges,
138+
challengesMeta: state.challenges.challengesMeta,
127139
bucket: state.filter.challenge.bucket,
128140
recommended: state.filter.challenge.recommended,
129141
recommendedChallenges: state.challenges.recommendedChallenges,

src/reducers/challenges.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const defaultState = {
44
loadingChallenges: false,
55
loadingChallengesError: null,
66
challenges: [],
7+
challengesMeta: {},
78
total: 0,
89
loadingRecommendedChallenges: false,
910
loadingRecommendedChallengesError: null,
@@ -31,6 +32,7 @@ function onGetChallengesDone(state, { payload }) {
3132
loadingChallenges: false,
3233
loadingChallengesError: null,
3334
challenges: payload.challenges,
35+
challengesMeta: payload.challenges?.meta,
3436
total: payload.total,
3537
openForRegistrationCount: payload.openForRegistrationCount,
3638
initialized: true,

0 commit comments

Comments
 (0)