"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _defineProperties(target,props){for(var descriptor,i=0;ithis.pagination.numPerPage?1:_Mathceil(this.pagination.totalItems/this.pagination.numPerPage),this.pagination.totalPages=_Mathmax(this.pagination.totalPages||0,1),$timeout(function(){return angular.element("body").scrollTo("#table-order-payment-head",50,{offset:{top:-300}})})}},{key:"pageReload",value:function pageReload(){return window.location.reload()}},{key:"setCookie",value:function setCookie(name,value,days){var date,expires;return expires="",days&&(date=new Date,date.setTime(date.getTime()+1e3*(60*(60*(24*days)))),expires="; expires="+date.toUTCString()),document.cookie=name+"="+(value||"")+expires+"; path=/"}},{key:"searchOrders",value:function searchOrders(){var dataToSend,_this=this;if(!this.isSubmitting)return this.isSubmitting=!0,dataToSend={action:"searchOrders",currentPage:this.pagination.currentPage,numPerPage:this.pagination.numPerPage,sortFields:config.sortFields.ordersList},$http.post(config.ordersInfoUrl,dataToSend).then(function(response){var data;if(data=response.data,_this.isSubmitting=!1,data)return data.isPhoneAuthorized?data.status&&"success"===data.status?_this.processSearchResponse(data):data.errors&&data.errors.length?_this.errors=data.errors:_this.errors=[config.global_labels.defaultErrorMessage.value]:(toastr.warning("\u041F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u044C \u043D\u0435 \u0430\u0432\u0442\u043E\u0440\u0438\u0437\u043E\u0432\u0430\u043D!"),$timeout(function(){return _this.setCookie("oip","",-1),_this.pageReload()},1200))})["catch"](function(response){return _this.errors=response.data&&response.data.errors?response.data.errors:[config.global_labels.defaultErrorMessage.value],_this.isSubmitting=!1})}},{key:"clearConfirmCodeResendTimeoutPromise",value:function clearConfirmCodeResendTimeoutPromise(){if(this.confirmCodeResendTimeoutPromise)return $interval.cancel(this.confirmCodeResendTimeoutPromise),this.confirmCodeResendTimeoutPromise=null}},{key:"startConfirmCodeResendTimeout",value:function startConfirmCodeResendTimeout(){var _this2=this;return this.confirmCodeResendTimeoutPromise=$interval(function(){if(_this2.confirmCodeResendTimeout--,0>=_this2.confirmCodeResendTimeout)return _this2.clearConfirmCodeResendTimeoutPromise()},1e3)}},{key:"tryToAuthorizePhone",value:function tryToAuthorizePhone(step){var dataToSend,_this3=this,cleanupConfirmCodeHash=!(1=this.confirmCodeResendTimeout)return this.tryToAuthorizePhone("enterPhone",!1);break;case"confirm":if(!this.isSubmitting)return this.errors=[],this.isSubmitting=!0,dataToSend={action:"checkConfirmCode",phoneToAuthorize:this.phoneToAuthorize,confirmCode:this.confirmCode,confirmCodeHash:this.confirmCodeHash},$http.post(config.ordersInfoAuthUrl,dataToSend).then(function(response){var data;return data=response.data,_this3.isSubmitting=!1,data?data.status&&"success"===data.status?data.isPhoneAuthorized?_this3.pageReload():(_this3.confirmCode="",data.tooManyCodeInputRetries&&(_this3.tooManyCodeInputRetries=!0),_this3.errors=data.errors):(_this3.confirmCode="",data.tooManyCodeInputRetries&&(_this3.tooManyCodeInputRetries=!0),_this3.errors=data.errors&&data.errors.length?data.errors:[config.global_labels.defaultErrorMessage.value]):(_this3.confirmCode="",data.tooManyCodeInputRetries&&(_this3.tooManyCodeInputRetries=!0),_this3.errors=data.errors&&data.errors.length?data.errors:[config.global_labels.defaultErrorMessage.value])})["catch"](function(response){return _this3.confirmCode="",_this3.errors=response.data&&response.data.errors?response.data.errors:[config.global_labels.defaultErrorMessage.value],_this3.isSubmitting=!1});}}}]),ordersInfoApp}();return ordersInfoApp.prototype.errors=[],ordersInfoApp.prototype.isSubmitting=!1,ordersInfoApp.prototype.ordersList=[],ordersInfoApp.prototype.phoneToAuthorize="",ordersInfoApp.prototype.phoneToAuthorizeStep="enterPhone",ordersInfoApp.prototype.confirmCodeIsSent=!1,ordersInfoApp.prototype.confirmCodeHash="",ordersInfoApp.prototype.tooManyCodeInputRetries=!1,ordersInfoApp.prototype.confirmCodeResendTimeout=0,ordersInfoApp.prototype.confirmCodeResendTimeoutPromise=null,ordersInfoApp.prototype.pagination={currentPage:1,numPerPage:20,totalItems:0,onWatchChange:function onWatchChange(newValue,oldValue){if(newValue!==oldValue)return $scope.ordersInfo.searchOrders()},setPage:function setPage(page){return page!==$scope.ordersInfo.pagination.currentPage&&($scope.ordersInfo.pagination.currentPage=page),$scope.ordersInfo.pagination.totalPages=0,$scope.ordersInfo.ordersList=[],$scope.ordersInfo.searchOrders()}},ordersInfoApp}.call(this),$scope.config=config,$scope.utilities=new UtilitiesClass(config,$filter,$timeout),$scope.ordersInfo=new ordersInfoApp,$scope.$watch("ordersInfo.pagination.currentPage",$scope.ordersInfo.pagination.onWatchChange),$scope.$watch("config.sortFields.ordersList.field",$scope.ordersInfo.pagination.onWatchChange),$scope.$watch("config.sortFields.ordersList.direction",$scope.ordersInfo.pagination.onWatchChange)}]);