Newer
Older
import * as authenticationActions from '../actions/AuthenticationActions'
loginPending: false,
showLoginDialog: false
};
function rootReducer(state = initialState, action) {
console.log("Bin im reducer: " + action.type)
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
switch (action.type) {
case authenticationActions.SHOW_LOGIN_DIALOG:
return {
...state,
showLoginDialog: true,
error: null
}
case authenticationActions.HIDE_LOGIN_DIALOG:
return {
...state,
showLoginDialog: false,
error: null
}
case authenticationActions.AUTHENTICATION_PENDING:
return {
...state,
pending: true,
error: null
}
case authenticationActions.AUTHENTICATION_SUCCESS:
return {
...state,
showLoginDialog: false,
pending: false,
user: action.user,
accessToken: action.accessToken
}
case authenticationActions.AUTHENTICATION_ERROR:
return {
...state,
pending: false,
error: 'Authentication failed'
}
default:
return state;
}