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 _reactNative=require("react-native");var _api=require("../../services/api");var _class,_descriptor,_descriptor2;var Store=(_class=function(){function Store(){(0,_classCallCheck2.default)(this,Store);(0,_initializerDefineProperty2.default)(this,"isLoading",_descriptor,this);(0,_initializerDefineProperty2.default)(this,"data",_descriptor2,this);}return(0,_createClass2.default)(Store,[{key:"getSchedulePayment",value:function getSchedulePayment(id,onSuccess,onError){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().getPaymentSchedule(id));case 1:response=_context.sent;this.isLoading=false;if(response.kind==='ok'){if(response.data.meta.errorCode===200){if(onSuccess)onSuccess(response.data.data);this.data=response.data.data;}else{_reactNative.Alert.alert('Thông báo',response.data.meta.errorMessage,[{text:'Đồng ý'}]);if(onError)onError();}}else{this.isLoading=false;if(onError)onError();_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);}}]);}(),_descriptor=(0,_applyDecoratedDescriptor2.default)(_class.prototype,"isLoading",[_mobx.observable],{configurable:true,enumerable:true,writable:true,initializer:function initializer(){return false;}}),_descriptor2=(0,_applyDecoratedDescriptor2.default)(_class.prototype,"data",[_mobx.observable],{configurable:true,enumerable:true,writable:true,initializer:function initializer(){return[];}}),(0,_applyDecoratedDescriptor2.default)(_class.prototype,"getSchedulePayment",[_mobx.action],Object.getOwnPropertyDescriptor(_class.prototype,"getSchedulePayment"),_class.prototype),_class);var SchedulePaymentStore=new Store();var _default=exports.default=SchedulePaymentStore;
//# sourceMappingURL=store.js.map