UNPKG

client-ui

Version:

Testing implementation of nodeJs Backend, angular frontend, and hopefully in a way that this can be deployed to s3/cloudfront

45 lines (38 loc) 1.8 kB
(function () { 'use strict'; angular.module('clientApp').controller('loanAgreementController', loanAgreementController); loanAgreementController.$inject = ['$state', 'client', 'loan', 'currentLoan', 'requiredDisclosures']; function loanAgreementController($state, clientService, loanService, currentLoan, requiredDisclosures) { var self = this; self.init = function () { self.loan = currentLoan; self.requiredDisclosures = requiredDisclosures; self.client = clientService.getClientStore(); self.config = config; loanService.getFirmOffer() .then(function (loanObject) { self.loan = loanService.getCurrentLoan(); self.done = true; }, function (error) { if (error && error.hasOwnProperty("code" && error.code === "SELECTED_OFFER_UNAVAILABLE")) { $state.transitionTo('loanApplication.loanOptions', {selectedOfferUnavailable: 'selectedOfferUnavailable'}); } else { self.errorMessage = "Something went wrong! We're really sorry, but you'll need to contact us to continue: " + globalConfig.company.phone.long; } }); }; self.acceptOffer = function () { if (self.laform.$invalid) { return; } self.working = true; loanService.acceptOffer().then(function () { self.working = false; $state.go('loanApplication.approved'); }, function (err) { self.errorMessage = 'Ooops... problem accepting loan'; self.working = false; }); }; } }());