2015-12-15 16:26:49 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import requests from '../utils/requests';
|
|
|
|
|
|
|
|
import EditionActions from '../actions/edition_actions';
|
|
|
|
|
|
|
|
|
|
|
|
const CoaSource = {
|
|
|
|
lookupCoa: {
|
2016-01-15 13:55:58 +01:00
|
|
|
remote(state, coaId) {
|
2015-12-17 15:46:30 +01:00
|
|
|
return requests
|
2016-01-15 13:55:58 +01:00
|
|
|
.get('coa', { id: coaId })
|
2015-12-17 15:46:30 +01:00
|
|
|
.then((res) => {
|
|
|
|
// If no coa is found here, fake a 404 error so the error action can pick it up
|
|
|
|
return (res && res.coa) ? res : Promise.reject({ json: { status: 404 } });
|
|
|
|
});
|
2015-12-15 16:26:49 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
success: EditionActions.successFetchCoa,
|
|
|
|
error: EditionActions.errorCoa
|
|
|
|
},
|
|
|
|
|
2016-01-15 13:55:58 +01:00
|
|
|
performCreateCoaForEdition: {
|
|
|
|
remote(state, editionId) {
|
|
|
|
return requests.post('coa_create', { body: { bitcoin_id: editionId } });
|
2015-12-15 16:26:49 +01:00
|
|
|
},
|
2016-01-15 13:55:58 +01:00
|
|
|
|
2015-12-15 16:26:49 +01:00
|
|
|
success: EditionActions.successFetchCoa,
|
|
|
|
error: EditionActions.errorCoa
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-12-17 15:46:30 +01:00
|
|
|
export default CoaSource;
|