(function() {
  'use strict';

  angular.module('Monitour.pages.password')
    .controller('pinCtrl', pinCtrl);

  /** @ngInject */
  function pinCtrl($scope, $location, ForgotpasswordService, $translate, SweetAlert, $stateParams) {
        
		var vm = this; 
   
	
		vm.pinnumber = pinnumber;
	
	   var user = $stateParams.user;
		
       console.log(user);		
		  function pinnumber() {
            vm.dataLoading = true;
			
			var pin =  { pin: vm.pin};
            ForgotpasswordService.Pin(pin)
                .then(function (response) {
					console.log(response.data.status);
                    if (response.data.status == 1) {
						  SweetAlert.swal({
            title: 'Success your Pin  details were correct!',
            text: '<span style="text-align:left; padding-bottom:15px; font-size:10px;">Please enter a new<span style="color:#08c"> password</span> for your account.</span>',
            html: true
        });
                      
					$state.go('pin', { 'user':  vm.email, 'pin': vm.pin });      
					   
					  
					  
                    } else {
						
						
						
                        SweetAlert.swal({
            title: 'Your Email details were incorrect!',
            text: '<span style="text-align:left; padding-bottom:15px; font-size:10px;">Please try again,<span style="color:#08c">with the correct </span> email address and password.</span>',
            html: true
        });
                        vm.dataLoading = 2;
                    }
                });
        }
		
		
	
    }

})();