diff --git a/js/sources/coa_source.js b/js/sources/coa_source.js new file mode 100644 index 00000000..88c72cce --- /dev/null +++ b/js/sources/coa_source.js @@ -0,0 +1,27 @@ +'use strict'; + +import requests from '../utils/requests'; + +import EditionActions from '../actions/edition_actions'; + + +const CoaSource = { + lookupCoa: { + remote(state) { + return requests.get('coa', { id: state.edition.coa }); + }, + + success: EditionActions.successFetchCoa, + error: EditionActions.errorCoa + }, + + performCreateCoa: { + remote(state) { + return requests.post('coa_create', {body: { bitcoin_id: state.edition.bitcoin_id }}); + }, + success: EditionActions.successFetchCoa, + error: EditionActions.errorCoa + } +}; + +export default CoaSource; \ No newline at end of file diff --git a/js/sources/edition_source.js b/js/sources/edition_source.js index 462205e0..3e48d257 100644 --- a/js/sources/edition_source.js +++ b/js/sources/edition_source.js @@ -13,25 +13,7 @@ const EditionSource = { success: EditionActions.successFetchEdition, error: EditionActions.errorEdition - }, - - // For COA - lookupCoa: { - remote(state) { - return requests.get('coa', { id: state.edition.coa }); - }, - - success: EditionActions.successFetchCoa, - error: EditionActions.errorCoa - }, - - performCreateCoa: { - remote(state) { - return requests.post('coa_create', {body: { bitcoin_id: state.edition.bitcoin_id }}); - }, - success: EditionActions.successFetchCoa, - error: EditionActions.errorCoa } }; -export default EditionSource; +export default EditionSource; \ No newline at end of file diff --git a/js/stores/edition_store.js b/js/stores/edition_store.js index ae728ef9..8fdd681b 100644 --- a/js/stores/edition_store.js +++ b/js/stores/edition_store.js @@ -5,6 +5,9 @@ import { alt } from '../alt'; import EditionActions from '../actions/edition_actions'; import EditionSource from '../sources/edition_source'; +import CoaSource from '../sources/coa_source'; + +import { mergeOptions } from '../utils/general_utils'; class EditionStore { @@ -19,7 +22,7 @@ class EditionStore { }; this.bindActions(EditionActions); - this.registerAsync(EditionSource); + this.registerAsync(mergeOptions(EditionSource, CoaSource)); } onFetchEdition(idToFetch) {