Start implementing backends and authentication

This commit is contained in:
Mathias Biilmann Christensen
2016-02-25 12:31:21 -08:00
parent c60d8ba706
commit 67cdd92bfb
13 changed files with 247 additions and 15 deletions

15
src/reducers/auth.js Normal file
View 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;
}
}

View File

@ -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) {

View File

@ -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;