1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00

Split EditionSource up into CoaSource and EditionSource

This commit is contained in:
Tim Daubenschütz 2015-12-09 13:18:07 +01:00
parent fb8111fadc
commit 2a251897d5
3 changed files with 30 additions and 18 deletions

27
js/sources/coa_source.js Normal file
View File

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

View File

@ -13,23 +13,6 @@ const EditionSource = {
success: EditionActions.successFetchEdition, success: EditionActions.successFetchEdition,
error: EditionActions.errorEdition error: EditionActions.errorEdition
},
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
} }
}; };

View File

@ -3,7 +3,9 @@
import { alt } from '../alt'; import { alt } from '../alt';
import EditionActions from '../actions/edition_actions'; import EditionActions from '../actions/edition_actions';
import EditionSource from '../sources/edition_source'; import EditionSource from '../sources/edition_source';
import CoaSource from '../sources/coa_source';
class EditionStore { class EditionStore {
@ -18,7 +20,7 @@ class EditionStore {
}; };
this.bindActions(EditionActions); this.bindActions(EditionActions);
this.registerAsync(EditionSource); this.registerAsync(Object.assign(EditionSource, CoaSource));
} }
onFetchEdition(idToFetch) { onFetchEdition(idToFetch) {