client/src/selectors/authSelectors.js
changeset 134 be36eed5e6e0
child 137 279e1dffa213
equal deleted inserted replaced
133:6f3078f7fd47 134:be36eed5e6e0
       
     1 // Selectors linked to the authentication status
       
     2 
       
     3 export const getOnline = state => state.getIn(["status", 'online'])
       
     4 
       
     5 export const getToken = state => state.getIn(['authStatus','token'])
       
     6 
       
     7 export const isAuthenticated = state => state.getIn(['authStatus', 'isAuthenticated'])
       
     8 
       
     9 export const getCurrentUser = state => state.getIn(['authStatus', 'currentUser'])
       
    10 
       
    11 export const getClientId = state => state.getIn(['authStatus', 'clientId'])
       
    12 
       
    13 export const getCurrentGroupName = state => state.getIn(['authStatus', 'currentGroup'])
       
    14 
       
    15 export const getGroups = state => state.get('groups')
       
    16 
       
    17 export const getCurrentGroup = state => {
       
    18   const groupName = getCurrentGroupName(state);
       
    19   const groups = getGroups(state);
       
    20   if(groups) {
       
    21     return groups.find( g => g.get('name') === groupName );
       
    22   } else {
       
    23     return null;
       
    24   }
       
    25 }
       
    26 
       
    27 export const getCreateGroup = state => state.get('createGroup')
       
    28 
       
    29 
       
    30