This commit is contained in:
enggar_ganteng 2019-01-06 00:33:30 +07:00
parent 295a125862
commit f1fdbbd6e6
4 changed files with 112 additions and 2 deletions

View File

@ -21,8 +21,12 @@ let type = 'akuntiket';
// apiUrl = "https://marketplace-sillyfish-staging-api.asacreative.com/v1/";
// imageUrl = "https://marketplace-sillyfish-staging-api.asacreative.com";
apiUrl = "https://marketplace-sillyfish-api.asacreative.com/v1/";
imageUrl = "https://marketplace-sillyfish-api.asacreative.com";
// apiUrl = "https://marketplace-sillyfish-api.asacreative.com/v1/";
// imageUrl = "https://marketplace-sillyfish-api.asacreative.com";
apiUrl = "https://giift-api.asacreative.com/";
imageUrl = "https://giift-api.asacreative.com";
type = 'localhost';
if(window.location.href.includes("localhost") || window.location.href.includes("marketplace-store")){
appUrl = 'http://localhost:7700'

View File

@ -32,9 +32,12 @@ export default class VouchersComponent extends React.Component {
},
};
this.defaultState = Object.assign({}, this.state);
this.vouchersStore = props.appstate.vouchers;
}
componentDidMount() {
this.vouchersStore.getList();
console.log('res list component',this.vouchersStore.getList())
}
render() {

View File

@ -56,6 +56,7 @@ import {Tags} from './tags';
import Surf from './surf';
import Odoo from './odoo';
import Vouchers from './vouchers';
export default class AppState {
http = new Http(this.token);
@ -101,6 +102,7 @@ export default class AppState {
userBanks = new UserBanks(this);
stores = new Stores(this);
storeList = new StoreList(this);
vouchers = new Vouchers(this);
userAddress = new UserAddress(this);
item = new ItemStore(this);
myStore = new MyStoreStore(this);

View File

@ -0,0 +1,101 @@
import { observable, action, computed } from 'mobx';
export default class Vouchers {
@observable list = [];
@observable selected = {};
@observable istLoading = false;
@observable isSearching = false;
@observable filtered = [];
constructor(context) {
this.http = context.http;
this.context = context;
}
@action
getList(){
console.log('res');
this.isLoading = true;
return this.http.get("items")
.then(res => {
console.log(res.data,'res list')
this.list = res.data;
this.isLoading = false;
})
.catch(err => {
this.isLoading = false;
throw err;
})
}
@action
getDetail(id){
this.isLoading = true;
return this.http.get(`stores/${id}`)
.then(res => {
this.selected = res;
this.isLoading = false;
})
.catch(err => {
this.isLoading = false;
throw err;
})
}
@action
post(data){
this.isLoading = true;
return this.http.post("stores", data)
.then(res => {
this.isLoading = false;
this.getList();
return res;
})
.catch(err => {
this.isLoading = false;
throw err;
})
}
@action
put(id,data){
this.isLoading = true;
return this.http.put(`stores/${id}`, data)
.then(res => {
this.isLoading = false;
this.getList();
return res;
})
.catch(err => {
this.isLoading = false;
throw err;
})
}
@action
delete(id){
this.isLoading = true;
return this.http.delete(`stores/${id}`)
.then(res => {
this.isLoading = false;
this.getList();
return res;
})
.catch(err => {
this.isLoading = false;
throw err;
})
}
filterItems = (query) => {
return this.list.filter((el) =>
el.name.toLowerCase().indexOf(query.toLowerCase()) > -1
);
}
@action
search(text){
this.filtered = this.filterItems(text);
}
}