Start implementing backends and authentication
This commit is contained in:
15
src/reducers/auth.js
Normal file
15
src/reducers/auth.js
Normal file
@ -0,0 +1,15 @@
|
||||
import Immutable from 'immutable';
|
||||
import { AUTH_REQUEST, AUTH_SUCCESS, AUTH_FAILURE } from '../actions/auth';
|
||||
|
||||
export function auth(state = null, action) {
|
||||
switch (action.type) {
|
||||
case AUTH_REQUEST:
|
||||
return Immutable.Map({isFetching: true});
|
||||
case AUTH_SUCCESS:
|
||||
return Immutable.fromJS({user: action.payload});
|
||||
case AUTH_FAILURE:
|
||||
return Immutable.Map({error: action.payload.toString()});
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
import Immutable from 'immutable';
|
||||
import { CONFIG } from '../actions/config';
|
||||
import { CONFIG_SUCCESS } from '../actions/config';
|
||||
|
||||
export function collections(state = null, action) {
|
||||
switch (action.type) {
|
||||
case CONFIG.SUCCESS:
|
||||
case CONFIG_SUCCESS:
|
||||
const collections = action.payload && action.payload.collections;
|
||||
return Immutable.OrderedMap().withMutations((map) => {
|
||||
(collections || []).forEach(function(collection) {
|
||||
|
@ -1,13 +1,13 @@
|
||||
import Immutable from 'immutable';
|
||||
import { CONFIG } from '../actions/config';
|
||||
import { CONFIG_REQUEST, CONFIG_SUCCESS, CONFIG_FAILURE } from '../actions/config';
|
||||
|
||||
export function config(state = null, action) {
|
||||
switch (action.type) {
|
||||
case CONFIG.REQUEST:
|
||||
case CONFIG_REQUEST:
|
||||
return Immutable.Map({isFetching: true});
|
||||
case CONFIG.SUCCESS:
|
||||
case CONFIG_SUCCESS:
|
||||
return Immutable.fromJS(action.payload);
|
||||
case CONFIG.FAILURE:
|
||||
case CONFIG_FAILURE:
|
||||
return Immutable.Map({error: action.payload.toString()});
|
||||
default:
|
||||
return state;
|
||||
|
Reference in New Issue
Block a user