import { ActionWithPayload , UserActions } from '../actions' ; import { User , Game , Friend , Invitation } from '../../../shared/model' ; import { Country } from 'shared-library/shared/mobile/component/countryList/model/country.model' ; export function user ( state = null , action ) { switch ( action . type ) { case UserActions . ADD_USER_WITH_ROLES : return action . payload ; default : return state ; } } export function userDict ( state = { } , action ) { switch ( action . type ) { case UserActions . LOAD_OTHER_USER_PROFILE_EXTENDED_INFO_SUCCESS : case UserActions . LOAD_OTHER_USER_PROFILE_SUCCESS : const users = { ... state } ; if ( action . payload ) { users [ action . payload . userId ] = { ... action . payload } ; } return users ; default : return state ; } } export function userFriendInvitations ( state = { } , action ) { switch ( action . type ) { case UserActions . LOAD_USER_INVITATION_INFO_SUCCESS : const invitations = { ... state } ; if ( action . payload ) { invitations [ action . payload . email ] = { ... action . payload } ; } return invitations ; default : return state ; } } export function authInitialized ( state = false , action ) { switch ( action . type ) { case UserActions . LOGOFF : case UserActions . ADD_USER_WITH_ROLES : return true ; default : return state ; } } export const getAuthorizationHeader = ( state ) => ( state ) ? 'Bearer ' + state . idToken : null ; export function invitationToken ( state = 'NONE' , action ) { switch ( action . type ) { case UserActions . STORE_INVITATION_TOKEN : return action . payload ; default : return state ; } } export function gameInvites ( state = [ ] , action ) { switch ( action . type ) { case UserActions . LOAD_GAME_INVITES_SUCCESS : return action . payload ; default : return state ; } } export function userFriends ( state = null , action ) { switch ( action . type ) { case UserActions . LOAD_USER_FRIENDS_SUCCESS : return action . payload ; default : return state ; } } export function friendInvitations ( state = [ ] , action ) { switch ( action . type ) { case UserActions . LOAD_FRIEND_INVITATION_SUCCESS : return action . payload ; default : return state ; } } export function userProfileSaveStatus ( state = 'NONE' , action ) { switch ( action . type ) { case UserActions . ADD_USER_PROFILE : return 'IN PROCESS' ; case UserActions . ADD_USER_PROFILE_SUCCESS : return 'SUCCESS' ; case UserActions . ADD_USER_INVITATION_SUCCESS : return action . payload ; case UserActions . MAKE_FRIEND_SUCCESS : return 'MAKE FRIEND SUCCESS' ; default : return null ; } } export function feedback ( state = 'NONE' , action ) { switch ( action . type ) { case UserActions . ADD_FEEDBACK : return action . payload ; case UserActions . ADD_FEEDBACK_SUCCESS : return 'SUCCESS' ; default : return null ; } } export function account ( state = null , action ) { switch ( action . type ) { case UserActions . LOAD_ACCOUNT_SUCCESS : return action . payload ; default : return state ; } } export function getGameResult ( state = [ ] , action ) { switch ( action . type ) { case UserActions . GET_GAME_RESULT_SUCCESS : return action . payload ; default : return state ; } } export function countries ( state = [ ] , action ) { switch ( action . type ) { case UserActions . LOAD_COUNTRIES_SUCCESS : return action . payload ; default : return state ; } } export function addressUsingLongLat ( state = null , action ) { switch ( action . type ) { case UserActions . LOAD_ADDRESS_USING_LAT_LONG_SUCCESS : return action . payload ; default : return null ; } } export function addressSuggestions ( state = null , action ) { switch ( action . type ) { case UserActions . LOAD_ADDRESS_SUGGESTIONS_SUCCESS : return action . payload ; default : return null ; } } export function checkDisplayName ( state = null , action ) { switch ( action . type ) { case UserActions . CHECK_DISPLAY_NAME_SUCCESS : return action . payload ; default : return null ; } } export function userUpdateStatus ( state = null , action ) { switch ( action . type ) { case UserActions . UPDATE_USER_SUCCESS : return action . payload ; default : return state ; } } export function firstQuestionBits ( state = null , action ) { switch ( action . type ) { case UserActions . SET_FIRST_QUESTION_BITS_SUCCESS : return action . payload ; default : return null ; } }