@@ -29,6 +29,10 @@ import _ from 'lodash'
2929import update from 'react-addons-update'
3030import { clean } from '../../helpers/utils'
3131
32+ export function getEmptyProjectObject ( ) {
33+ return { invites : [ ] , members : [ ] }
34+ }
35+
3236const initialState = {
3337 isLoading : true ,
3438 processing : false ,
@@ -41,12 +45,11 @@ const initialState = {
4145 attachmentTags : null ,
4246 error : false ,
4347 inviteError : false ,
44- project : {
45- members : [ ] ,
46- invites : [ ] // invites are pushed directly into it hence need to declare first
47- } ,
48+ // invites are pushed directly into it hence need to declare first
49+ // using the getEmptyProjectObject method
50+ project : getEmptyProjectObject ( ) ,
4851 assetsMembers : { } ,
49- projectNonDirty : { } ,
52+ projectNonDirty : getEmptyProjectObject ( ) ,
5053 updateExisting : false ,
5154 phases : null ,
5255 phasesNonDirty : null ,
@@ -188,8 +191,8 @@ export const projectState = function (state=initialState, action) {
188191 case LOAD_PROJECT_PENDING :
189192 return Object . assign ( { } , state , {
190193 isLoading : true ,
191- project : null ,
192- projectNonDirty : null
194+ project : getEmptyProjectObject ( ) ,
195+ projectNonDirty : getEmptyProjectObject ( ) ,
193196 } )
194197
195198 case LOAD_PROJECT_SUCCESS :
@@ -352,8 +355,8 @@ export const projectState = function (state=initialState, action) {
352355 case GET_PROJECTS_SUCCESS :
353356 return Object . assign ( { } , state , {
354357 isLoading : true , // this is excpected to be default value when there is not project loaded
355- project : { } ,
356- projectNonDirty : { } ,
358+ project : getEmptyProjectObject ( ) ,
359+ projectNonDirty : getEmptyProjectObject ( ) ,
357360 phases : null ,
358361 phasesNonDirty : null ,
359362 } )
@@ -523,8 +526,8 @@ export const projectState = function (state=initialState, action) {
523526 return Object . assign ( { } , state , {
524527 processing : false ,
525528 error : false ,
526- project : { } ,
527- projectNonDirty : { }
529+ project : getEmptyProjectObject ( ) ,
530+ projectNonDirty : getEmptyProjectObject ( ) ,
528531 } )
529532
530533 // Project attachments
0 commit comments