Skip to content

Commit 1e3c8e0

Browse files
authored
Merge pull request #1649 from topcoder-platform/pm-1214
fix(PM-1214): pagination in submissions tab
2 parents 1fc4c52 + cd5322c commit 1e3c8e0

File tree

7 files changed

+185
-286
lines changed

7 files changed

+185
-286
lines changed

src/actions/challengeSubmissions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { fetchSubmissions } from '../services/challenges'
22

33
import { LOAD_CHALLENGE_SUBMISSIONS } from '../config/constants'
44

5-
export function loadSubmissions (challengeId) {
6-
return dispatch => {
5+
export function loadSubmissions (challengeId, page) {
6+
return (dispatch) => {
77
if (challengeId) {
88
dispatch({
99
type: LOAD_CHALLENGE_SUBMISSIONS,
10-
payload: fetchSubmissions(challengeId)
10+
payload: fetchSubmissions(challengeId, page)
1111
})
1212
}
1313
}

src/components/ChallengeEditor/ChallengeViewTabs/index.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ const ChallengeViewTabs = ({
5555
loggedInUser,
5656
onApproveChallenge,
5757
createResource,
58-
deleteResource
58+
deleteResource,
59+
loadSubmissions,
60+
totalSubmissions,
61+
submissionsPerPage,
62+
page
5963
}) => {
6064
const [selectedTab, setSelectedTab] = useState(0)
6165
const [showAddResourceModal, setShowAddResourceModal] = useState(false)
@@ -114,7 +118,7 @@ const ChallengeViewTabs = ({
114118
})
115119
return s
116120
})
117-
}, [challengeSubmissions, allResources])
121+
}, [challengeSubmissions, allResources, page])
118122

119123
const isTask = _.get(challenge, 'task.isTask', false)
120124

@@ -298,7 +302,7 @@ const ChallengeViewTabs = ({
298302
>
299303
RESOURCES
300304
</a>
301-
{challengeSubmissions.length ? (
305+
{totalSubmissions ? (
302306
<a
303307
tabIndex='2'
304308
role='tab'
@@ -311,7 +315,7 @@ const ChallengeViewTabs = ({
311315
}}
312316
className={getSelectorStyle(selectedTab, 2)}
313317
>
314-
SUBMISSIONS ({submissions.length})
318+
SUBMISSIONS ({totalSubmissions})
315319
</a>
316320
) : null}
317321
</div>
@@ -353,6 +357,10 @@ const ChallengeViewTabs = ({
353357
submissions={submissions}
354358
token={token}
355359
loggedInUserResource={loggedInUserResource}
360+
loadSubmissions={loadSubmissions}
361+
totalSubmissions={totalSubmissions}
362+
submissionsPerPage={submissionsPerPage}
363+
page={page}
356364
/>
357365
)}
358366
{showAddResourceModal ? (<ResourcesAdd
@@ -396,7 +404,11 @@ ChallengeViewTabs.propTypes = {
396404
deleteResource: PropTypes.func.isRequired,
397405
showRejectChallengeModal: PropTypes.func.isRequired,
398406
loggedInUser: PropTypes.object.isRequired,
399-
onApproveChallenge: PropTypes.func
407+
onApproveChallenge: PropTypes.func,
408+
loadSubmissions: PropTypes.func,
409+
totalSubmissions: PropTypes.number,
410+
submissionsPerPage: PropTypes.number,
411+
page: PropTypes.number
400412
}
401413

402414
export default ChallengeViewTabs

src/components/ChallengeEditor/Submissions/Submissions.module.scss

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,3 +401,25 @@ $base-unit: 5px;
401401
overflow: hidden;
402402
}
403403
}
404+
405+
.paginationWrapper {
406+
display: flex;
407+
margin-top: 30px;
408+
flex: 1;
409+
justify-content: center;
410+
}
411+
412+
.footer {
413+
display: flex;
414+
justify-content: flex-end;
415+
margin-top: 30px;
416+
}
417+
418+
.perPageContainer {
419+
margin-right: 20px;
420+
max-width: 150px;
421+
}
422+
423+
.paginationContainer {
424+
display: flex;
425+
}

0 commit comments

Comments
 (0)