Skip to content

Commit 5776ab1

Browse files
committed
Change to show challenges related to logged in user.
1 parent 9f049d6 commit 5776ab1

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

src/actions/challenges.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import { removeChallengeFromPhaseProduct, saveChallengeAsPhaseProduct } from '..
6565
* @param {string} filterChallengeName
6666
* @param {bool} selfService
6767
* @param {string} userHandle this will be null for admin user(we will return all datas for admin user)
68+
* @param {number} userId this will be null for admin user(we will return all datas for admin user)
6869
* @param {string} filterChallengeType
6970
* @param {object} filterDate
7071
* @param {string} filterSortBy
@@ -79,6 +80,7 @@ export function loadChallengesByPage (
7980
filterChallengeName = null,
8081
selfService = false,
8182
userHandle = null,
83+
userId = 0,
8284
filterChallengeType = {},
8385
filterDate = {},
8486
filterSortBy = null,
@@ -138,8 +140,8 @@ export function loadChallengesByPage (
138140
if (filterSortBy) {
139141
filters['sortBy'] = filterSortBy
140142
}
141-
if (userHandle) {
142-
filters['createdBy'] = userHandle
143+
if (userId) {
144+
filters['memberId'] = userId
143145
}
144146
if (filterSortOrder) {
145147
filters['sortOrder'] = filterSortOrder

src/components/ChallengesComponent/ChallengeList/index.js

Lines changed: 20 additions & 1 deletion
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.getUserId(),
119120
challengeType,
120121
challengeDate
121122
)
@@ -152,6 +153,7 @@ class ChallengeList extends Component {
152153
searchText,
153154
selfService,
154155
this.getHandle(),
156+
this.getUserId(),
155157
filterChallengeType,
156158
filterDate,
157159
sortBy,
@@ -189,6 +191,7 @@ class ChallengeList extends Component {
189191
searchText,
190192
selfService,
191193
this.getHandle(),
194+
this.getUserId(),
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.getUserId()
220224
)
221225
}
222226

@@ -254,12 +258,25 @@ class ChallengeList extends Component {
254258
return this.getLoginHandle()
255259
}
256260

261+
getUserId () {
262+
if (checkAdmin(this.props.auth.token)) {
263+
return null
264+
}
265+
return this.getLoginUserId()
266+
}
267+
257268
getLoginHandle () {
258269
return this.props.auth && this.props.auth.user
259270
? this.props.auth.user.handle
260271
: null
261272
}
262273

274+
getLoginUserId () {
275+
return this.props.auth && this.props.auth.user
276+
? this.props.auth.user.userId
277+
: null
278+
}
279+
263280
/**
264281
* Hide error message
265282
*/
@@ -294,6 +311,7 @@ class ChallengeList extends Component {
294311
searchText,
295312
selfService,
296313
this.getHandle(),
314+
this.getUserId(),
297315
challengeType,
298316
challengeDate,
299317
name,
@@ -339,6 +357,7 @@ class ChallengeList extends Component {
339357
'',
340358
selfService,
341359
this.getHandle(),
360+
this.getUserId(),
342361
null,
343362
{},
344363
null,

src/containers/Challenges/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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+
isAdmin ? null : this.props.auth.user.userId
8889
)
8990
const projectLoading =
9091
window.localStorage.getItem('projectLoading') !== null

0 commit comments

Comments
 (0)