Skip to content

Commit 11adadb

Browse files
committed
Filter challenges by logged in user
1 parent f2b2b2b commit 11adadb

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

src/actions/challenges.js

+4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export function loadChallengesByPage (
6666
filterChallengeName = null,
6767
selfService = false,
6868
userHandle = null,
69+
filterCreatedBy = null,
6970
filterChallengeType = {},
7071
filterDate = {},
7172
filterSortBy = null,
@@ -125,6 +126,9 @@ export function loadChallengesByPage (
125126
if (filterSortBy) {
126127
filters['sortBy'] = filterSortBy
127128
}
129+
if (filterCreatedBy) {
130+
filters['createdBy'] = filterCreatedBy
131+
}
128132
if (filterSortOrder) {
129133
filters['sortOrder'] = filterSortOrder
130134
}

src/components/ChallengesComponent/ChallengeList/index.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class ChallengeList extends Component {
116116
searchText,
117117
selfService,
118118
this.getHandle(),
119+
this.getLoginHandle(),
119120
challengeType,
120121
challengeDate
121122
)
@@ -152,6 +153,7 @@ class ChallengeList extends Component {
152153
searchText,
153154
selfService,
154155
this.getHandle(),
156+
this.getLoginHandle(),
155157
filterChallengeType,
156158
filterDate,
157159
sortBy,
@@ -189,6 +191,7 @@ class ChallengeList extends Component {
189191
searchText,
190192
selfService,
191193
this.getHandle(),
194+
this.getLoginHandle(),
192195
filterChallengeType,
193196
filterDate,
194197
sortBy,
@@ -216,7 +219,8 @@ class ChallengeList extends Component {
216219
status,
217220
searchText,
218221
selfService,
219-
this.getHandle()
222+
this.getHandle(),
223+
this.getLoginHandle()
220224
)
221225
}
222226

@@ -251,6 +255,10 @@ class ChallengeList extends Component {
251255
if (checkAdmin(this.props.auth.token)) {
252256
return null
253257
}
258+
return this.getLoginHandle()
259+
}
260+
261+
getLoginHandle () {
254262
return this.props.auth && this.props.auth.user
255263
? this.props.auth.user.handle
256264
: null
@@ -290,6 +298,7 @@ class ChallengeList extends Component {
290298
searchText,
291299
selfService,
292300
this.getHandle(),
301+
this.getLoginHandle(),
293302
challengeType,
294303
challengeDate,
295304
name,
@@ -335,6 +344,7 @@ class ChallengeList extends Component {
335344
'',
336345
selfService,
337346
this.getHandle(),
347+
this.getLoginHandle(),
338348
null,
339349
{},
340350
null,

src/containers/Challenges/index.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Challenges extends Component {
4444
} = this.props
4545
loadChallengeTypes()
4646
if (dashboard) {
47-
this.reloadChallenges(this.props, true)
47+
this.reloadChallenges(this.props, true, true)
4848
}
4949
if (menu === 'NULL' && activeProjectId !== -1) {
5050
resetSidebarActiveParams()
@@ -62,11 +62,11 @@ class Challenges extends Component {
6262
(nextProps.dashboard && this.props.dashboard !== nextProps.dashboard) ||
6363
this.props.activeProjectId !== nextProps.activeProjectId
6464
) {
65-
this.reloadChallenges(nextProps)
65+
this.reloadChallenges(nextProps, false, true)
6666
}
6767
}
6868

69-
reloadChallenges (props, forceLoad) {
69+
reloadChallenges (props, forceLoad, loadMyChallenge) {
7070
const {
7171
activeProjectId,
7272
projectDetail: reduxProjectInfo,
@@ -84,7 +84,8 @@ class Challenges extends Component {
8484
dashboard ? 'all' : '',
8585
'',
8686
selfService,
87-
isAdmin ? null : this.props.auth.user.handle
87+
isAdmin ? null : this.props.auth.user.handle,
88+
loadMyChallenge ? this.props.auth.user.handle : ''
8889
)
8990
const projectLoading =
9091
window.localStorage.getItem('projectLoading') !== null

0 commit comments

Comments
 (0)