mirror of
https://github.com/ascribe/onion.git
synced 2024-11-15 01:25:17 +01:00
59 lines
1.6 KiB
JavaScript
59 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
import alt from '../alt';
|
|
import OwnershipFetcher from '../fetchers/ownership_fetcher';
|
|
import Q from 'q';
|
|
|
|
class ContractListActions {
|
|
constructor() {
|
|
this.generateActions(
|
|
'updateContractList',
|
|
'flushContractList'
|
|
);
|
|
}
|
|
|
|
fetchContractList(isActive, isPublic, issuer) {
|
|
return Q.Promise((resolve, reject) => {
|
|
OwnershipFetcher.fetchContractList(isActive, isPublic, issuer)
|
|
.then((contracts) => {
|
|
this.actions.updateContractList(contracts.results);
|
|
resolve(contracts.results);
|
|
})
|
|
.catch((err) => {
|
|
console.logGlobal(err);
|
|
this.actions.updateContractList([]);
|
|
reject(err);
|
|
});
|
|
});
|
|
}
|
|
|
|
|
|
changeContract(contract){
|
|
return Q.Promise((resolve, reject) => {
|
|
OwnershipFetcher.changeContract(contract)
|
|
.then((res) => {
|
|
resolve(res);
|
|
})
|
|
.catch((err)=> {
|
|
console.logGlobal(err);
|
|
reject(err);
|
|
});
|
|
});
|
|
}
|
|
|
|
removeContract(contractId){
|
|
return Q.Promise( (resolve, reject) => {
|
|
OwnershipFetcher.deleteContract(contractId)
|
|
.then((res) => {
|
|
resolve(res);
|
|
})
|
|
.catch( (err) => {
|
|
console.logGlobal(err);
|
|
reject(err);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
export default alt.createActions(ContractListActions);
|