mirror of
https://github.com/ascribe/onion.git
synced 2024-11-16 01:55:07 +01:00
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
import alt from '../alt';
|
|
import OwnershipFetcher from '../fetchers/ownership_fetcher';
|
|
|
|
|
|
class LoanContractActions {
|
|
constructor() {
|
|
this.generateActions(
|
|
'updateLoanContract'
|
|
);
|
|
}
|
|
|
|
fetchLoanContract(email) {
|
|
|
|
if(email.match(/.+\@.+\..+/)) {
|
|
OwnershipFetcher.fetchLoanContract(email)
|
|
.then((contracts) => {
|
|
if (contracts && contracts.length > 0) {
|
|
this.actions.updateLoanContract({
|
|
contractKey: contracts[0].s3Key,
|
|
contractUrl: contracts[0].s3Url
|
|
});
|
|
}
|
|
else {
|
|
this.actions.updateLoanContract({
|
|
contractKey: null,
|
|
contractUrl: null
|
|
});
|
|
}
|
|
})
|
|
.catch((err) => {
|
|
console.error(err);
|
|
this.actions.updateLoanContract({
|
|
contractKey: null,
|
|
contractUrl: null
|
|
});
|
|
});
|
|
} else {
|
|
/* No email was entered - Ignore and keep going*/
|
|
}
|
|
}
|
|
}
|
|
|
|
export default alt.createActions(LoanContractActions);
|