@@ -4,14 +4,17 @@ import {
44 SET_SEARCH_TERM , SET_PROJECTS_SEARCH_CRITERIA ,
55 CLEAR_PROJECT_SUGGESTIONS_SEARCH , PROJECT_SUGGESTIONS_SEARCH_SUCCESS ,
66 SET_PROJECTS_INFINITE_AUTOLOAD ,
7- SET_PROJECTS_LIST_VIEW
7+ SET_PROJECTS_LIST_VIEW ,
8+ PROJECT_STATUS_ACTIVE ,
9+ ROLE_TOPCODER_USER
810} from '../../config/constants'
911import { getProjects } from '../../api/projects'
1012import { loadMembers } from '../../actions/members'
1113
1214// ignore action
1315/*eslint-disable no-unused-vars */
1416const getProjectsWithMembers = ( dispatch , getState , criteria , pageNum ) => {
17+ const state = getState ( )
1518 return new Promise ( ( resolve , reject ) => {
1619 dispatch ( {
1720 type : SET_PROJECTS_SEARCH_CRITERIA ,
@@ -21,7 +24,26 @@ const getProjectsWithMembers = (dispatch, getState, criteria, pageNum) => {
2124
2225 return dispatch ( {
2326 type : GET_PROJECTS ,
24- payload : getProjects ( criteria , pageNum ) ,
27+ payload : getProjects ( criteria , pageNum )
28+ . then ( ( originalData ) => {
29+ const retryForCustomer = criteria . status === PROJECT_STATUS_ACTIVE && state . loadUser . user . roles && state . loadUser . user . roles . length === 1
30+ && state . loadUser . user . roles [ 0 ] === ROLE_TOPCODER_USER
31+ if ( originalData . totalCount === 0 && retryForCustomer ) {
32+ //retrying for customer if active projects are 0 but there are some projects with other status
33+ //This is to bypass the walkthrough page which we ideally show for customer with zero projects
34+ const newCriteria = {
35+ sort : 'updatedAt desc'
36+ }
37+ return getProjects ( newCriteria , pageNum )
38+ . then ( ( allProjectsData ) => {
39+ //add allprojects count to be updated to redux store
40+ originalData . allProjectsCount = allProjectsData . totalCount
41+ return originalData
42+ } )
43+ } else {
44+ return originalData
45+ }
46+ } ) ,
2547 meta : {
2648 // keep previous to enable the loading without paginator (infinite scroll)
2749 keepPrevious : pageNum !== 1
0 commit comments