72 lines
1.9 KiB
JavaScript
72 lines
1.9 KiB
JavaScript
import { observable, action, computed } from 'mobx';
|
|
|
|
export default class UserBanks {
|
|
|
|
@observable banks = [];
|
|
@observable isLoading = false;
|
|
@observable bankId = '';
|
|
|
|
constructor(context) {
|
|
this.http = context.http;
|
|
this.globalUI = context.globalUI;
|
|
this.context = context;
|
|
}
|
|
|
|
@action
|
|
getAllBanks(){
|
|
this.globalUI.openLoading();
|
|
return this.http.get(`user_banks`).then(res=>{
|
|
this.banks = res;
|
|
this.globalUI.closeLoading();
|
|
})
|
|
}
|
|
|
|
@action
|
|
getAllBanksAdmin(id){
|
|
this.globalUI.openLoading();
|
|
return this.http.get(`user_banks?user_store_id=${id}`).then(res=>{
|
|
this.banks = res;
|
|
this.globalUI.closeLoading();
|
|
})
|
|
}
|
|
|
|
@action
|
|
addBank(data){
|
|
this.globalUI.openLoading();
|
|
return this.http.post(`user_banks`,data).then(res=>{
|
|
this.getAllBanks();
|
|
this.globalUI.closeLoading();
|
|
})
|
|
}
|
|
|
|
@action
|
|
addBankAdmin(id,data){
|
|
this.globalUI.openLoading();
|
|
return this.http.post(`user_banks?user_store_id=${id}`,data).then(res=>{
|
|
this.getAllBanksAdmin(id);
|
|
this.globalUI.closeLoading();
|
|
})
|
|
}
|
|
|
|
@action
|
|
updateBank(data){
|
|
|
|
this.globalUI.openLoading();
|
|
return this.http.put(`user_banks/${data.id}`,data).then(res=>{
|
|
this.getAllBanks();
|
|
this.globalUI.closeLoading();
|
|
})
|
|
}
|
|
|
|
@action
|
|
updateBankAdmin(store_id,data){
|
|
this.globalUI.openLoading();
|
|
return this.http.put(`user_banks/${data.id}?user_store_id=${store_id}`,data).then(res=>{
|
|
this.getAllBanksAdmin(store_id);
|
|
this.globalUI.closeLoading();
|
|
})
|
|
}
|
|
|
|
|
|
}
|