File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * Sidebar related redux actions
3
+ */
4
+ import { fetchMemberProjects } from '../services/projects'
5
+ import {
6
+ LOAD_ALL_USER_PROJECTS_PENDING ,
7
+ LOAD_ALL_USER_PROJECTS_SUCCESS ,
8
+ LOAD_ALL_USER_PROJECTS_FAILURE
9
+ } from '../config/constants'
10
+
11
+ /**
12
+ * Loads projects of the authenticated user
13
+ */
14
+ export function loadAllUserProjects ( isAdmin = true ) {
15
+ return ( dispatch ) => {
16
+ dispatch ( {
17
+ type : LOAD_ALL_USER_PROJECTS_PENDING
18
+ } )
19
+
20
+ const filters = {
21
+ status : 'active' ,
22
+ sort : 'lastActivityAt desc'
23
+ }
24
+ if ( ! isAdmin ) {
25
+ filters [ 'memberOnly' ] = true
26
+ }
27
+
28
+ fetchMemberProjects ( filters ) . then ( projects => dispatch ( {
29
+ type : LOAD_ALL_USER_PROJECTS_SUCCESS ,
30
+ projects
31
+ } ) ) . catch ( ( ) => dispatch ( {
32
+ type : LOAD_ALL_USER_PROJECTS_FAILURE
33
+ } ) )
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments