var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.Types=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator"));var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));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 _reactNative=require("react-native");var _log=require("../utils/log");var _class,_descriptor,_descriptor2,_descriptor3;var Types=exports.Types=function(Types){Types[Types["Province"]=0]="Province";Types[Types["District"]=1]="District";Types[Types["Ward"]=2]="Ward";Types[Types["Reason"]=3]="Reason";Types[Types["Job"]=4]="Job";Types[Types["Bank"]=5]="Bank";return Types;}({});var SelectorStore=(_class=function(){function SelectorStore(){(0,_classCallCheck2.default)(this,SelectorStore);(0,_initializerDefineProperty2.default)(this,"isLoading",_descriptor,this);(0,_initializerDefineProperty2.default)(this,"isError",_descriptor2,this);(0,_initializerDefineProperty2.default)(this,"data",_descriptor3,this);}return(0,_createClass2.default)(SelectorStore,[{key:"getData",value:function getData(params,type,onSuccess,onFailure){var response,_t,_t2;return _regenerator.default.async(function(_context){while(1)switch(_context.prev=_context.next){case 0:this.isLoading=true;this.data=[];response={};_t=type;_context.next=_t===Types.Province?1:_t===Types.District?3:_t===Types.Ward?5:_t===Types.Reason?7:_t===Types.Job?9:_t===Types.Bank?11:13;break;case 1:_context.next=2;return _regenerator.default.awrap(_api.Api.getInstance().getProvinces(params));case 2:response=_context.sent;return _context.abrupt("continue",13);case 3:_context.next=4;return _regenerator.default.awrap(_api.Api.getInstance().getDistricts(params));case 4:response=_context.sent;return _context.abrupt("continue",13);case 5:_context.next=6;return _regenerator.default.awrap(_api.Api.getInstance().getWards(params));case 6:response=_context.sent;return _context.abrupt("continue",13);case 7:_context.next=8;return _regenerator.default.awrap(_api.Api.getInstance().loanPurpose(params));case 8:response=_context.sent;return _context.abrupt("continue",13);case 9:_context.next=10;return _regenerator.default.awrap(_api.Api.getInstance().getJobs(params));case 10:response=_context.sent;return _context.abrupt("continue",13);case 11:_context.next=12;return _regenerator.default.awrap(_api.Api.getInstance().getBanks(params));case 12:response=_context.sent;return _context.abrupt("continue",13);case 13:if(!(response.kind==='ok')){_context.next=17;break;}this.isLoading=false;this.isError=false;_t2=type;_context.next=_t2===Types.Reason?14:15;break;case 14:this.data=response.data.data.map(function(item){return(0,_extends2.default)({},item,{name:item.text});});return _context.abrupt("continue",16);case 15:this.data=response.data.data;return _context.abrupt("continue",16);case 16:(0,_log.myLog)(response.data.data);if(onSuccess){onSuccess(response.data.data);}_context.next=18;break;case 17:this.isLoading=false;this.isError=false;_reactNative.Alert.alert('Lỗi',response.Messages);case 18: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,"isError",[_mobx.observable],{configurable:true,enumerable:true,writable:true,initializer:function initializer(){return false;}}),_descriptor3=(0,_applyDecoratedDescriptor2.default)(_class.prototype,"data",[_mobx.observable],{configurable:true,enumerable:true,writable:true,initializer:function initializer(){return[];}}),(0,_applyDecoratedDescriptor2.default)(_class.prototype,"getData",[_mobx.action],Object.getOwnPropertyDescriptor(_class.prototype,"getData"),_class.prototype),_class);var _default=exports.default=SelectorStore;
//# sourceMappingURL=SelectorStore.js.map