1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2024-10-30 15:50:04 -04:00
moneygo/js/reducers/TransactionPageReducer.js

41 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-05-22 20:36:36 -04:00
var assign = require('object-assign');
var TransactionPageConstants = require('../constants/TransactionPageConstants');
var UserConstants = require('../constants/UserConstants');
var Account = require('../models').Account;
module.exports = function(state = {account: new Account(), pageSize: 1, page: 0, numPages: 0, transactions: [], endingBalance: "0" }, action) {
switch (action.type) {
case TransactionPageConstants.FETCH_TRANSACTION_PAGE:
return {
account: action.account,
pageSize: action.pageSize,
page: action.page,
numPages: 0,
transactions: [],
endingBalance: "0"
};
case TransactionPageConstants.TRANSACTION_PAGE_FETCHED:
return {
account: action.account,
pageSize: action.pageSize,
page: action.page,
numPages: action.numPages,
transactions: action.transactions,
endingBalance: action.endingBalance
};
case UserConstants.USER_LOGGEDOUT:
return {
account: new Account(),
pageSize: 1,
page: 0,
numPages: 0,
transactions: [],
endingBalance: "0"
};
default:
return state;
}
};