var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _initializerDefineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/initializerDefineProperty"));var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _applyDecoratedDescriptor2=_interopRequireDefault(require("@babel/runtime/helpers/applyDecoratedDescriptor"));var _initializerWarningHelper2=_interopRequireDefault(require("@babel/runtime/helpers/initializerWarningHelper"));var _mobx=require("mobx");var _api=require("../../services/api");var _log=require("../../utils/log");var _reactNative=require("react-native");var _class,_descriptor,_descriptor2,_descriptor3,_descriptor4;var Store=(_class=function(){function Store(){(0,_classCallCheck2.default)(this,Store);(0,_initializerDefineProperty2.default)(this,"photo",_descriptor,this);(0,_initializerDefineProperty2.default)(this,"isLoading",_descriptor2,this);(0,_initializerDefineProperty2.default)(this,"isError",_descriptor3,this);(0,_initializerDefineProperty2.default)(this,"photoBase64",_descriptor4,this);}return(0,_createClass2.default)(Store,[{key:"uploadImage",value:function uploadImage(body,onSuccess,onFailure){var response;return _regenerator.default.async(function(_context){while(1)switch(_context.prev=_context.next){case 0:this.isLoading=true;_context.next=1;return _regenerator.default.awrap(_api.Api.getInstance().uploadImage(body));case 1:response=_context.sent;this.isLoading=false;(0,_log.myLog)(response);if(response.kind==='ok'){if(response.data.meta.errorCode===200){this.isError=false;(0,_log.myLog)('data',response.data.data);if(onSuccess){onSuccess(response.data.data);}}else{_reactNative.Alert.alert('Thông báo',response.data.meta.errorMessage,[{text:'Đồng ý'}]);if(onFailure)onFailure();}}else{this.isLoading=false;this.isError=false;if(onFailure)onFailure();_reactNative.Alert.alert('Thông báo','Có lỗi xảy ra. Vui lòng thử lại sau');}case 2:case"end":return _context.stop();}},null,this,null,Promise);}},{key:"checkSelfieImage",value:function checkSelfieImage(body,loanBriefId,onSuccess,onError){var response;return _regenerator.default.async(function(_context2){while(1)switch(_context2.prev=_context2.next){case 0:this.isLoading=true;_context2.next=1;return _regenerator.default.awrap(_api.Api.getInstance().checkSelfieImage(body,loanBriefId));case 1:response=_context2.sent;this.isLoading=false;(0,_log.myLog)(response);if(response.kind==='ok'){if(response.data.meta.errorCode===200){this.isError=false;(0,_log.myLog)('data',response.data.data);if(onSuccess){onSuccess(response.data.data);}}else{_reactNative.Alert.alert('Thông báo',response.data.meta.errorMessage,[{text:'Đồng ý'}]);onError();}}else{this.isLoading=false;this.isError=false;onError();_reactNative.Alert.alert('Lỗi','Có lỗi xảy ra. Vui lòng thử lại');}case 2:case"end":return _context2.stop();}},null,this,null,Promise);}}]);}(),_descriptor=(0,_applyDecoratedDescriptor2.default)(_class.prototype,"photo",[_mobx.observable],{configurable:true,enumerable:true,writable:true,initializer:null}),_descriptor2=(0,_applyDecoratedDescriptor2.default)(_class.prototype,"isLoading",[_mobx.observable],{configurable:true,enumerable:true,writable:true,initializer:function initializer(){return false;}}),_descriptor3=(0,_applyDecoratedDescriptor2.default)(_class.prototype,"isError",[_mobx.observable],{configurable:true,enumerable:true,writable:true,initializer:function initializer(){return false;}}),_descriptor4=(0,_applyDecoratedDescriptor2.default)(_class.prototype,"photoBase64",[_mobx.observable],{configurable:true,enumerable:true,writable:true,initializer:function initializer(){return undefined;}}),(0,_applyDecoratedDescriptor2.default)(_class.prototype,"uploadImage",[_mobx.action],Object.getOwnPropertyDescriptor(_class.prototype,"uploadImage"),_class.prototype),_class);var selfieStore=new Store();var _default=exports.default=selfieStore;
//# sourceMappingURL=SelfieStore.js.map