2015-08-26 09:50:38 +02:00
|
|
|
'use strict';
|
|
|
|
|
2015-10-06 16:47:59 +02:00
|
|
|
import { alt } from '../alt';
|
2015-08-26 09:50:38 +02:00
|
|
|
import OwnershipFetcher from '../fetchers/ownership_fetcher';
|
|
|
|
|
|
|
|
|
|
|
|
class OwnershipActions {
|
|
|
|
constructor() {
|
|
|
|
this.generateActions(
|
|
|
|
'updateLoanPieceRequestList',
|
2015-08-26 15:46:27 +02:00
|
|
|
'updateLoanPieceRequest',
|
|
|
|
'flushLoanPieceRequest'
|
2015-08-26 09:50:38 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
fetchLoanRequestList() {
|
|
|
|
OwnershipFetcher.fetchLoanPieceRequestList()
|
|
|
|
.then((data) => {
|
|
|
|
this.actions.updateLoanPieceRequestList(data.loan_requests);
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
console.logGlobal(err);
|
|
|
|
this.actions.updateLoanPieceRequestList(null);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
fetchLoanRequest(pieceId) {
|
|
|
|
OwnershipFetcher.fetchLoanPieceRequestList()
|
|
|
|
.then((data) => {
|
2015-08-26 15:46:27 +02:00
|
|
|
this.actions.updateLoanPieceRequest({loanRequests: data.loan_requests, pieceId: pieceId});
|
2015-08-26 09:50:38 +02:00
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
console.logGlobal(err);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default alt.createActions(OwnershipActions);
|