twreporter-react
Version:
React-Redux site for The Reporter Foundation in Taiwan
44 lines (37 loc) • 1.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _actionTypes = require('../constants/action-types');
var types = _interopRequireWildcard(_actionTypes);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function article() {
var state = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var action = arguments[1];
switch (action.type) {
case types.FETCH_ARTICLE_REQUEST:
return Object.assign({}, state, {
isFetching: true,
slug: action.slug,
error: null
});
case types.FETCH_ARTICLE_FAILURE:
return Object.assign({}, state, {
isFetching: false,
slug: action.slug,
error: action.error,
lastUpdated: action.failedAt
});
case types.FETCH_ARTICLE_SUCCESS:
return Object.assign({}, state, {
isFetching: false,
error: null,
id: action.response.result,
slug: action.slug,
lastUpdated: action.receivedAt
});
default:
return state;
}
}
exports.default = article;