UNPKG

client-ui

Version:

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

61 lines (52 loc) 2.21 kB
(function () { 'use strict'; angular.module(moduleName).controller('emailController', emailController); emailController.$inject = ['loan', 'client', 'currentLoan', 'clientData', '$state', 'stateChangeManager']; function emailController(loanService, clientService, currentLoan, clientData, $state, stateChangeManager) { var self = this; self.clientData = clientData; self.currentLoan = currentLoan; self.goToNextStep = goToNextStep; self.verifyEmailInit = verifyEmailInit; self.refreshEmailVerification = refreshEmailVerification; self.resendEmailVerification = resendEmailVerification; function verifyEmailInit() { if (!self.clientData.emailVerified) { stateChangeManager.doUntilStateChange(self.refreshEmailVerification, 5000); } } function refreshEmailVerification() { return clientService.getClient() .then(function (clientData) { self.clientData = clientData; if (self.clientData.emailVerified) { stateChangeManager.doTasks(); } }, function (error) { handleError(error); }); } function resendEmailVerification() { self.working = true; return clientService.resendVerificationEmail(self.clientData.clientId) .then(function (response) { self.emailVerError = false; self.emailVerSuccess = true; self.working = false; }, function (error) { self.emailVerError = true; self.emailVerSuccess = false; self.working = false; handleError(error); }); } function goToNextStep() { self.working = false; $state.go(loanService.getNextStep()); } function handleError(res) { self.working = false; console.info(res); } } })();