Skip to content

Commit 22cd966

Browse files
committed
For admin, fetch all projects
1 parent 86e5ca3 commit 22cd966

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/actions/sidebar.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
UNLOAD_PROJECTS_SUCCESS,
1212
PROJECTS_PAGE_SIZE
1313
} from '../config/constants'
14+
import { checkAdmin } from '../util/tc'
1415
import _ from 'lodash'
1516

1617
/**
@@ -29,7 +30,7 @@ export function setActiveProject (projectId) {
2930
/**
3031
* Loads projects of the authenticated user
3132
*/
32-
export function loadProjects (filterProjectName = '', myProjects = true, paramFilters = {}) {
33+
export function loadProjects (filterProjectName = '', paramFilters = {}) {
3334
return (dispatch, getState) => {
3435
dispatch({
3536
type: LOAD_PROJECTS_PENDING
@@ -48,18 +49,18 @@ export function loadProjects (filterProjectName = '', myProjects = true, paramFi
4849
}
4950
}
5051

51-
if (myProjects) {
52+
if (!checkAdmin(getState().auth.token)) {
5253
filters['memberOnly'] = true
5354
}
5455

56+
// eslint-disable-next-line no-debugger
5557
const state = getState().sidebar
56-
// eslint-disable-next-line no-sequences
57-
fetchMemberProjects(filters).then(({ projects, pagination }) => (console.log('here', pagination), dispatch({
58+
fetchMemberProjects(filters).then(({ projects, pagination }) => dispatch({
5859
type: LOAD_PROJECTS_SUCCESS,
5960
projects: _.uniqBy((state.projects || []).concat(projects), 'id'),
6061
total: pagination.xTotal,
6162
page: pagination.xPage
62-
}))).catch(() => dispatch({
63+
})).catch(() => dispatch({
6364
type: LOAD_PROJECTS_FAILURE
6465
}))
6566
}
@@ -68,19 +69,19 @@ export function loadProjects (filterProjectName = '', myProjects = true, paramFi
6869
/**
6970
* Load more projects for the authenticated user
7071
*/
71-
export function loadMoreProjects (filterProjectName = '', myProjects = true, paramFilters = {}) {
72+
export function loadMoreProjects (filterProjectName = '', paramFilters = {}) {
7273
return (dispatch, getState) => {
7374
const state = getState().sidebar
7475

75-
loadProjects(filterProjectName, myProjects, _.assignIn({}, paramFilters, {
76+
loadProjects(filterProjectName, _.assignIn({}, paramFilters, {
7677
perPage: PROJECTS_PAGE_SIZE,
7778
page: state.page + 1
7879
}))(dispatch, getState)
7980
}
8081
}
8182

82-
export function loadTaasProjects (filterProjectName = '', myProjects = true, paramFilters = {}) {
83-
return loadProjects(filterProjectName, myProjects, Object.assign({
83+
export function loadTaasProjects (filterProjectName = '', paramFilters = {}) {
84+
return loadProjects(filterProjectName, Object.assign({
8485
type: 'talent-as-a-service'
8586
}, paramFilters))
8687
}

src/actions/users.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function loadAllUserProjects (isAdmin = true) {
2828
filters['memberOnly'] = true
2929
}
3030

31-
fetchMemberProjects(filters).then(projects => dispatch({
31+
fetchMemberProjects(filters).then(({ projects }) => dispatch({
3232
type: LOAD_ALL_USER_PROJECTS_SUCCESS,
3333
projects
3434
})).catch(() => dispatch({

0 commit comments

Comments
 (0)