bukopin-redemption-client-r.../src/common/stores/transaction.js
Rifqy Zacky Ariadhy 1a000700e6 Initial commit
2019-01-02 18:39:53 +07:00

153 lines
3.1 KiB
JavaScript

import { observable, action, computed } from 'mobx';
export default class Transaction {
@observable isLoading = false;
@observable list = [];
@observable transactionListFiltered = [];
@observable transactionList = [
{
id : '47efc62f-fb69-427a-9a12-51eac2c45e75',
payment_proof : '',
amount : '500000',
status : 'Waiting Approval',
transaction_id: '47efc62f-fb69-427a-9a12-51eac2c45e75',
user_id: '47efc62f-fb69-427a-9a12-51eac2c45e75',
approver_user_id:'',
type: 'Withdraw',
bank_account_number : 'T3ST4J4',
bank_name : 'BCA',
reject_reason : '',
bank_behalf_of : 'Sunshine Store',
bank_to: 'Admin Martketplace',
user : {
username : 'sunshine',
email : 'store@marketplace.com',
}
}
];
@observable detail = {
"payment_proof": "",
"amount": "",
"status": "",
account:{
id: '',
name : '',
},
"approver_user_id": null,
"bank_account_number": "",
"bank_name": "",
"reject_reason": null,
"bank_behalf_of": "",
"bank_to": {
"name": "",
"account_number": "",
"on_behalf": ""
},
"type": "",
created_at :'',
transaction : {
id : '',
status : '',
amount : '',
created_at : '',
}
};
@observable saldo = [
{
amount : 0
},{
amount : 0
}];
@observable wallet ={
pending_payment_to_wallet : 0,
balance : 0
}
constructor(context) {
this.context = context;
this.http = context.http;
}
@action
reset(){
this.detail = {
"payment_proof": "",
"amount": "",
"status": "",
account:{
id: '',
name : '',
},
"approver_user_id": null,
"bank_account_number": "",
"bank_name": "",
"reject_reason": null,
"bank_behalf_of": "",
"bank_to": {
"name": "",
"account_number": "",
"on_behalf": ""
},
"type": "",
created_at :'',
transaction : {
id : '',
status : '',
amount : '',
created_at : '',
}
};
}
// @action
// getAll() {
// this.isLoading = true;
// return this.http.get("transaction")
// .then(res => {
// this.isLoading = false;
// this.list = res;
// })
// }
@action
getAll() {
this.isLoading = true;
return this.http.get("transaction")
.then(res => {
this.list = res;
this.isLoading = false;
})
.catch(err => {
this.isLoading = false;
throw err;
})
}
@action
getAmount(){
return this.http.get(`wallet`).then(res => {
this.wallet = res;
});
}
@action
getById(id) {
this.isLoading = true;
return this.http.get(`transaction/${id}`).then(res => {
this.detail = res;
this.isLoading = false;
});
}
filterItems = (query) => {
return this.transactionList.filter((el) =>
el.user.email.toLowerCase().indexOf(query.toLowerCase()) > -1
);
}
@action
search(text){
// var a = _.filter(this.tasks,function(o){return _.includes(o,text)});
this.transactionListFiltered = this.filterItems(text);
}
}