Saving and fetching of documents

This commit is contained in:
Jori Lallo
2016-05-19 20:46:34 -07:00
parent 58e588a6fd
commit 4430a3129e
14 changed files with 332 additions and 16 deletions

63
src/reducers/document.js Normal file
View File

@@ -0,0 +1,63 @@
import {
FETCH_DOCUMENT_PENDING,
FETCH_DOCUMENT_SUCCESS,
FETCH_DOCUMENT_FAILURE,
SAVE_DOCUMENT_PENDING,
SAVE_DOCUMENT_SUCCESS,
SAVE_DOCUMENT_FAILURE,
} from 'actions/DocumentActions';
const initialState = {
data: null,
error: null,
isLoading: false,
}
const doc = (state = initialState, action) => {
switch (action.type) {
case FETCH_DOCUMENT_PENDING: {
return {
...state,
isLoading: true,
};
}
case FETCH_DOCUMENT_SUCCESS: {
return {
data: action.data,
isLoading: false,
};
}
case FETCH_DOCUMENT_FAILURE: {
return {
...state,
error: action.error,
isLoading: false,
};
}
case SAVE_DOCUMENT_PENDING: {
return {
...state,
isLoading: true,
};
}
case SAVE_DOCUMENT_SUCCESS: {
return {
data: action.date,
isLoading: false,
};
}
case SAVE_DOCUMENT_FAILURE: {
return {
...state,
error: action.error,
isLoading: false,
};
}
default:
return state;
}
};
export default doc;