Initial commit
This commit is contained in:
17
js/reducers/ErrorReducer.js
Normal file
17
js/reducers/ErrorReducer.js
Normal file
@ -0,0 +1,17 @@
|
||||
var ErrorConstants = require('../constants/ErrorConstants');
|
||||
|
||||
var Error = require('../models').Error;
|
||||
|
||||
module.exports = function(state = new Error(), action) {
|
||||
switch (action.type) {
|
||||
case ErrorConstants.ERROR_AJAX:
|
||||
case ErrorConstants.ERROR_SERVER:
|
||||
case ErrorConstants.ERROR_CLIENT:
|
||||
case ErrorConstants.ERROR_USER:
|
||||
return action.error;
|
||||
case ErrorConstants.CLEAR_ERROR:
|
||||
return new Error();
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
11
js/reducers/LunchReducer.js
Normal file
11
js/reducers/LunchReducer.js
Normal file
@ -0,0 +1,11 @@
|
||||
var Redux = require('redux');
|
||||
|
||||
var UserReducer = require('./UserReducer');
|
||||
var SessionReducer = require('./SessionReducer');
|
||||
var ErrorReducer = require('./ErrorReducer');
|
||||
|
||||
module.exports = Redux.combineReducers({
|
||||
user: UserReducer,
|
||||
session: SessionReducer,
|
||||
error: ErrorReducer
|
||||
});
|
14
js/reducers/SessionReducer.js
Normal file
14
js/reducers/SessionReducer.js
Normal file
@ -0,0 +1,14 @@
|
||||
var UserConstants = require('../constants/UserConstants');
|
||||
|
||||
var Session = require('../models').Session;
|
||||
|
||||
module.exports = function(state = new Session(), action) {
|
||||
switch (action.type) {
|
||||
case UserConstants.USER_LOGGEDIN:
|
||||
return action.session;
|
||||
case UserConstants.USER_LOGGEDOUT:
|
||||
return new Session();
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
15
js/reducers/UserReducer.js
Normal file
15
js/reducers/UserReducer.js
Normal file
@ -0,0 +1,15 @@
|
||||
var UserConstants = require('../constants/UserConstants');
|
||||
|
||||
var User = require('../models').User;
|
||||
|
||||
module.exports = function(state = new User(), action) {
|
||||
switch (action.type) {
|
||||
case UserConstants.USER_FETCHED:
|
||||
case UserConstants.USER_UPDATED:
|
||||
return action.user;
|
||||
case UserConstants.USER_LOGGEDOUT:
|
||||
return new User();
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user