-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Erik Rasmussen
committed
Aug 21, 2015
1 parent
af04168
commit 3fdf194
Showing
20 changed files
with
195 additions
and
258 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
const LOAD = 'redux-example/auth/LOAD'; | ||
const LOAD_SUCCESS = 'redux-example/auth/LOAD_SUCCESS'; | ||
const LOAD_FAIL = 'redux-example/auth/LOAD_FAIL'; | ||
const LOGIN = 'redux-example/auth/LOGIN'; | ||
const LOGIN_SUCCESS = 'redux-example/auth/LOGIN_SUCCESS'; | ||
const LOGIN_FAIL = 'redux-example/auth/LOGIN_FAIL'; | ||
const LOGOUT = 'redux-example/auth/LOGOUT'; | ||
const LOGOUT_SUCCESS = 'redux-example/auth/LOGOUT_SUCCESS'; | ||
const LOGOUT_FAIL = 'redux-example/auth/LOGOUT_FAIL'; | ||
|
||
const initialState = { | ||
loaded: false | ||
}; | ||
|
||
export default function reducer(state = initialState, action = {}) { | ||
switch (action.type) { | ||
case LOAD: | ||
return { | ||
...state, | ||
loading: true | ||
}; | ||
case LOAD_SUCCESS: | ||
return { | ||
...state, | ||
loading: false, | ||
loaded: true, | ||
user: action.result | ||
}; | ||
case LOAD_FAIL: | ||
return { | ||
...state, | ||
loading: false, | ||
loaded: false, | ||
error: action.error | ||
}; | ||
case LOGIN: | ||
return { | ||
...state, | ||
loggingIn: true | ||
}; | ||
case LOGIN_SUCCESS: | ||
return { | ||
...state, | ||
loggingIn: false, | ||
user: action.result | ||
}; | ||
case LOGIN_FAIL: | ||
return { | ||
...state, | ||
loggingIn: false, | ||
user: null, | ||
loginError: action.error | ||
}; | ||
case LOGOUT: | ||
return { | ||
...state, | ||
loggingOut: true | ||
}; | ||
case LOGOUT_SUCCESS: | ||
return { | ||
...state, | ||
loggingOut: false, | ||
user: null | ||
}; | ||
case LOGOUT_FAIL: | ||
return { | ||
...state, | ||
loggingOut: false, | ||
logoutError: action.error | ||
}; | ||
default: | ||
return state; | ||
} | ||
} | ||
|
||
export function isLoaded(globalState) { | ||
return globalState.auth && globalState.auth.loaded; | ||
} | ||
|
||
export function load() { | ||
return { | ||
types: [LOAD, LOAD_SUCCESS, LOAD_FAIL], | ||
promise: (client) => client.get('/loadAuth') | ||
}; | ||
} | ||
|
||
export function login(name) { | ||
return { | ||
types: [LOGIN, LOGIN_SUCCESS, LOGIN_FAIL], | ||
promise: (client) => client.post('/login', { | ||
data: { | ||
name: name | ||
} | ||
}) | ||
}; | ||
} | ||
|
||
export function logout() { | ||
return { | ||
types: [LOGOUT, LOGOUT_SUCCESS, LOGOUT_FAIL], | ||
promise: (client) => client.get('/logout') | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const INCREMENT = 'redux-example/counter/INCREMENT'; | ||
|
||
const initialState = { | ||
count: 0 | ||
}; | ||
|
||
export default function reducer(state = initialState, action = {}) { | ||
switch (action.type) { | ||
case INCREMENT: | ||
const {count} = state; | ||
return { | ||
count: count + 1 | ||
}; | ||
default: | ||
return state; | ||
} | ||
} | ||
|
||
export function increment() { | ||
return { | ||
type: INCREMENT | ||
}; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
I think these should be 'redux-example/info/...'. Right?