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 _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _mobx=require("mobx");var _api=require("../../services/api");var _reactNative=require("react-native");var Store=function(){function Store(){(0,_classCallCheck2.default)(this,Store);(0,_defineProperty2.default)(this,"isLoading",false);(0,_mobx.makeAutoObservable)(this);}return(0,_createClass2.default)(Store,[{key:"addNfcData",value:function addNfcData(body,onSuccess,onError){var response,_response$data$meta,_t;return _regenerator.default.async(function(_context){while(1)switch(_context.prev=_context.next){case 0:this.isLoading=true;_context.prev=1;_context.next=2;return _regenerator.default.awrap(_api.Api.getInstance().addNfcData(body));case 2:response=_context.sent;this.isLoading=false;if(response.kind==="ok"){if(response.data.meta.errorCode===200){if(onSuccess)onSuccess();}else{_reactNative.Alert.alert("Thông báo",(_response$data$meta=response.data.meta)==null?void 0:_response$data$meta.errorMessage);if(onError)onError();}}else{_reactNative.Alert.alert("Thông báo","Có lỗi xảy ra. Vui lòng thử lại sau");if(onError)onError();}_context.next=4;break;case 3:_context.prev=3;_t=_context["catch"](1);console.log(_t);this.isLoading=false;case 4:case"end":return _context.stop();}},null,this,[[1,3]],Promise);}}]);}();var nfcStore=new Store();var _default=exports.default=nfcStore;
//# sourceMappingURL=store.js.map