summaryrefslogtreecommitdiff
path: root/frontend/src/redux/user.js
blob: 0279b49c5c3fae88b7d2ebefa0176edb8eb54e83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { fromJS } from 'immutable'

export const types = {
  SET_USERNAME: 'USER/SET_USERNAME',
}

export const setUsername = (userName, displayName, index) => ({
  type: types.SET_USERNAME,
  userName,
  index,
  displayName
})

const initialState = fromJS({
  username: '',
  displayName: '',
  id: null
})

export default (state = initialState, action) => {
  switch (action.type) {
    case types.SET_USERNAME:
      return state.set('username', action.userName)
        .set('displayName', action.displayName)
        .set('id', action.index)
    default:
      return state
  }
}
bgstack15