Skip to content

Commit 4ec89b1

Browse files
committed
fix: pagination in submissions tab
1 parent 1fc4c52 commit 4ec89b1

File tree

7 files changed

+185
-287
lines changed

7 files changed

+185
-287
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ $base-unit: 5px;
269269
.submissionsContainerTable {
270270
width: auto;
271271
max-width: 100%;
272-
overflow: auto;
273272

274273
table {
275274
width: 100%;
@@ -401,3 +400,25 @@ $base-unit: 5px;
401400
overflow: hidden;
402401
}
403402
}
403+
404+
.paginationWrapper {
405+
display: flex;
406+
margin-top: 30px;
407+
flex: 1;
408+
justify-content: center;
409+
}
410+
411+
.footer {
412+
display: flex;
413+
justify-content: flex-end;
414+
margin-top: 30px;
415+
}
416+
417+
.perPageContainer {
418+
margin-right: 20px;
419+
max-width: 150px;
420+
}
421+
422+
.paginationContainer {
423+
display: flex;
424+
}

0 commit comments

Comments
 (0)