Perbaikan PPOB
This commit is contained in:
		| @@ -9,6 +9,11 @@ export class Membership { | ||||
|  | ||||
|     dataDetail = {}; | ||||
|  | ||||
|  | ||||
|     //filter | ||||
|     visibleModalFilterMembership = false; | ||||
|     filterMembership = null; | ||||
|     filterPartner = null; | ||||
|     constructor(ctx) { | ||||
|         this.ctx = ctx; | ||||
|         makeAutoObservable(this); | ||||
| @@ -16,8 +21,10 @@ export class Membership { | ||||
|  | ||||
|     async getData() { | ||||
|         try { | ||||
|             const response = await http.get(`/users?page=${this.page}&pageSize=${this.pageSize}`); | ||||
|             //console.log(response) | ||||
|             const response = await http.get(`/users?page=${this.page}&pageSize=${this.pageSize}&superrior=${this.filterMembership}&type=${this.filterPartner}`); | ||||
|             // console.log(this.filterMembership) | ||||
|             // console.log(this.filterPartner) | ||||
|             // console.log(response) | ||||
|             this.data = response.body.data.map((item, idx) => { | ||||
|                 item.key = idx; | ||||
|                 item.name = item?.user_detail?.name; | ||||
|   | ||||
| @@ -13,7 +13,10 @@ export class Payback { | ||||
|   pageSizeConfirmation = 10; | ||||
|   dataConfirmation = []; | ||||
|   totalDataConfirmation = 0; | ||||
|   //data=[] | ||||
|  | ||||
|     //filter | ||||
|     visibleModalFilterPayback = false; | ||||
|   constructor(ctx) { | ||||
|     this.ctx = ctx; | ||||
|     makeAutoObservable(this); | ||||
| @@ -21,8 +24,7 @@ export class Payback { | ||||
|  | ||||
|   async getDataCreated() { | ||||
|     try { | ||||
|       const response = await http.get( | ||||
|           `/transaction/deposit-return?page=${this.pageCreated}&pageSize=${this.pageSizeCreated}` | ||||
|       const response = await http.get(`/transaction/deposit-return?page=${this.pageCreated}&pageSize=${this.pageSizeCreated}` | ||||
|       ); | ||||
|       this.dataCreated = response.body.data.map((item, idx) => { | ||||
|         item.key = idx; | ||||
| @@ -40,6 +42,7 @@ export class Payback { | ||||
|       const response = await http.get( | ||||
|           `/transaction/deposit-return/confirmation?page=${this.pageConfirmation}&pageSize=${this.pageSizeConfirmation}` | ||||
|       ); | ||||
|       console.log(response) | ||||
|       this.dataConfirmation = response.body.data.map((item, idx) => { | ||||
|         item.key = idx; | ||||
|         return item; | ||||
| @@ -84,6 +87,8 @@ export class Payback { | ||||
|   async confirmPayback(id, data) { | ||||
|     try { | ||||
|       const response = await http.put(`/transaction/deposit-return/confirmation/${id}/${data}`); | ||||
|       // console.log(response) | ||||
|       // this.data=response.body.data | ||||
|       await Promise.all([ | ||||
|         this.getDataConfirmation(), | ||||
|         this.getDataCreated() | ||||
|   | ||||
| @@ -1,150 +1,165 @@ | ||||
| import {makeAutoObservable} from "mobx"; | ||||
| import {http} from "../utils/http"; | ||||
| import { makeAutoObservable } from "mobx"; | ||||
| import { http } from "../utils/http"; | ||||
|  | ||||
| export class Transaction { | ||||
|     page = 0; | ||||
|     pageSize = 10 | ||||
|     data = []; | ||||
|     total_data = 0; | ||||
|     filterSubCategory = null; | ||||
|     visibleModalProduct = false; | ||||
|     visibleModalTransaction = false; | ||||
|   page = 0; | ||||
|   pageSize = 10; | ||||
|   data = []; | ||||
|   total_data = 0; | ||||
|   filterSubCategory = null; | ||||
|   visibleModalProduct = false; | ||||
|   visibleModalTransaction = false; | ||||
|  | ||||
|     pageCategories = 0; | ||||
|     pageSizeCategories = 10 | ||||
|     dataCategories = []; | ||||
|     total_dataCategories = 0; | ||||
|   pageCategories = 0; | ||||
|   pageSizeCategories = 10; | ||||
|   dataCategories = []; | ||||
|   total_dataCategories = 0; | ||||
|  | ||||
|     pageSubCategories = 0; | ||||
|     pageSizeSubCategories = 10 | ||||
|     dataSubCategories = []; | ||||
|     total_dataSubCategories = 0; | ||||
|     filterSubCategory = null; | ||||
|   pageSubCategories = 0; | ||||
|   pageSizeSubCategories = 10; | ||||
|   dataSubCategories = []; | ||||
|   total_dataSubCategories = 0; | ||||
|   filterSubCategory = null; | ||||
|  | ||||
|     pageHistoryTransaction = 0; | ||||
|     pageSizeHistoryTransaction = 10 | ||||
|     dataHistoryTransaction = []; | ||||
|     total_dataHistoryTransaction = 0; | ||||
|   pageHistoryTransaction = 0; | ||||
|   pageSizeHistoryTransaction = 10; | ||||
|   dataHistoryTransaction = []; | ||||
|   total_dataHistoryTransaction = 0; | ||||
|  | ||||
|     pageHistoryTopUp = 0; | ||||
|     pageSizeHistoryTopUp = 10; | ||||
|     dataHistoryTopUp = []; | ||||
|     total_dataHistoryTopUp = 0; | ||||
|   pageHistoryTopUp = 0; | ||||
|   pageSizeHistoryTopUp = 10; | ||||
|   dataHistoryTopUp = []; | ||||
|   total_dataHistoryTopUp = 0; | ||||
|  | ||||
|     constructor(ctx) { | ||||
|         this.ctx = ctx; | ||||
|         makeAutoObservable(this); | ||||
|   //filter | ||||
|   visibleModalFilterTransaction = false; | ||||
|   filterStart = null; | ||||
|   filterEnd = null; | ||||
|   constructor(ctx) { | ||||
|     this.ctx = ctx; | ||||
|     makeAutoObservable(this); | ||||
|   } | ||||
|  | ||||
|   async getData() { | ||||
|     try { | ||||
|       const response = await http.get( | ||||
|         `/product/by-categories-all?sub-category=${this.filterSubCategory}&page=${this.page}&pageSize=${this.pageSize}` | ||||
|       ); | ||||
|       this.data = response.body.data ?? []; | ||||
|       this.total_data = response?.body?.count ?? 0; | ||||
|     } catch (e) { | ||||
|       console.error(e); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|     async getData() { | ||||
|         try { | ||||
|             const response = await http.get(`/product/by-categories-all?sub-category=${this.filterSubCategory}&page=${this.page}&pageSize=${this.pageSize}`); | ||||
|             this.data = response.body.data ?? [] | ||||
|             this.total_data = response?.body?.count ?? 0 | ||||
|         } catch (e) { | ||||
|             console.error(e); | ||||
|         } | ||||
|   async getDataSubCategories() { | ||||
|     try { | ||||
|       const response = await http.get( | ||||
|         `/product/sub-categories?category=${this.filterCategory}&page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}` | ||||
|       ); | ||||
|       this.dataSubCategories = response.body.data ?? []; | ||||
|       this.total_dataSubCategories = response.body.count ?? 0; | ||||
|     } catch (e) { | ||||
|       console.error(e); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|     async getDataSubCategories() { | ||||
|         try { | ||||
|             const response = await http.get(`/product/sub-categories?category=${this.filterCategory}&page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}`); | ||||
|             this.dataSubCategories = response.body.data ?? [] | ||||
|             this.total_dataSubCategories = response.body.count ?? 0 | ||||
|         } catch (e) { | ||||
|             console.error(e); | ||||
|         } | ||||
|   async getDataCategories() { | ||||
|     try { | ||||
|       const response = await http.get( | ||||
|         `/product/categories?page=${this.pageCategories}&pageSize=${this.pageSizeCategories}` | ||||
|       ); | ||||
|       this.dataCategories = response.body.data ?? []; | ||||
|       this.total_dataCategories = response?.body?.count ?? 0; | ||||
|       if (this.dataCategories.length > 0) { | ||||
|         this.filterCategory = this.dataCategories[0].id; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       console.error(e); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|     async getDataCategories() { | ||||
|         try { | ||||
|             const response = await http.get(`/product/categories?page=${this.pageCategories}&pageSize=${this.pageSizeCategories}`); | ||||
|             this.dataCategories = response.body.data ?? [] | ||||
|             this.total_dataCategories = response?.body?.count ?? 0 | ||||
|             if (this.dataCategories.length > 0) { | ||||
|                 this.filterCategory = this.dataCategories[0].id | ||||
|             } | ||||
|         } catch (e) { | ||||
|             console.error(e); | ||||
|         } | ||||
|   async getDataHistoryTransaction() { | ||||
|     try { | ||||
|       const response = await http.get( | ||||
|         `/transaction/history?page=${this.pageHistoryTransaction}&pageSize=${this.pageSizeHistoryTransaction}&start=${this.filterStart}&end=${this.filterEnd}` | ||||
|       ); | ||||
|       console.log(response); | ||||
|       this.dataHistoryTransaction = response.body.data ?? []; | ||||
|       this.total_dataHistoryTransaction = response?.body?.count ?? 0; | ||||
|     } catch (e) { | ||||
|       console.error(e); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|     async getDataHistoryTransaction() { | ||||
|         try { | ||||
|             const response = await http.get(`/transaction/history?page=${this.pageHistoryTransaction}&pageSize=${this.pageSizeHistoryTransaction}`); | ||||
|             this.dataHistoryTransaction = response.body.data ?? [] | ||||
|             this.total_dataHistoryTransaction = response?.body?.count ?? 0 | ||||
|         } catch (e) { | ||||
|             console.error(e); | ||||
|         } | ||||
|   async getDataHistoryTopUp(id) { | ||||
|     try { | ||||
|       const response = await http.get( | ||||
|         `/transaction/history-deposit?page=${this.pageHistoryTopUp}&pageSize=${this.pageSizeHistoryTopUp}&user-destination=${id}` | ||||
|       ); | ||||
|       this.dataHistoryTopUp = response.body.data ?? []; | ||||
|       this.total_dataHistoryTopUp = response?.body?.count ?? 0; | ||||
|     } catch (e) { | ||||
|       console.error(e); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|     async getDataHistoryTopUp(id) { | ||||
|         try { | ||||
|             const response = await http.get(`/transaction/history-deposit?page=${this.pageHistoryTopUp}&pageSize=${this.pageSizeHistoryTopUp}&user-destination=${id}`); | ||||
|             this.dataHistoryTopUp = response.body.data ?? [] | ||||
|             this.total_dataHistoryTopUp = response?.body?.count ?? 0 | ||||
|         } catch (e) { | ||||
|             console.error(e); | ||||
|         } | ||||
|   async create(data) { | ||||
|     try { | ||||
|       const response = await http.post("/product").send(data); | ||||
|       await this.getData(); | ||||
|       return response; | ||||
|     } catch (e) { | ||||
|       console.error(e); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|     async create(data) { | ||||
|         try { | ||||
|             const response = await http.post('/product').send(data); | ||||
|             await this.getData(); | ||||
|             return response; | ||||
|         } catch (e) { | ||||
|             console.error(e); | ||||
|         } | ||||
|   async buyProduct(data) { | ||||
|     try { | ||||
|       const response = await http.post("/transaction/order").send(data); | ||||
|       return response; | ||||
|     } catch (e) { | ||||
|       console.error(e); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|     async buyProduct(data) { | ||||
|         try { | ||||
|             const response = await http.post('/transaction/order').send(data); | ||||
|             return response; | ||||
|         } catch (e) { | ||||
|             console.error(e); | ||||
|         } | ||||
|   async update(id, data) { | ||||
|     try { | ||||
|       const response = await http.put(`/product/${id}`).send(data); | ||||
|       await this.getData(); | ||||
|       return response; | ||||
|     } catch (e) { | ||||
|       console.error(e); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|     async update(id, data) { | ||||
|         try { | ||||
|             const response = await http.put(`/product/${id}`).send(data); | ||||
|             await this.getData(); | ||||
|             return response; | ||||
|         } catch (e) { | ||||
|             console.error(e); | ||||
|         } | ||||
|   async delete(id) { | ||||
|     try { | ||||
|       const response = await http.del(`/product/${id}`); | ||||
|       await this.getData(); | ||||
|       return response; | ||||
|     } catch (e) { | ||||
|       console.error(e); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|     async delete(id) { | ||||
|         try { | ||||
|             const response = await http.del(`/product/${id}`); | ||||
|             await this.getData(); | ||||
|             return response; | ||||
|         } catch (e) { | ||||
|             console.error(e); | ||||
|         } | ||||
|   async distribute(data) { | ||||
|     try { | ||||
|       const response = await http.post("/transaction/distribute").send(data); | ||||
|       return response; | ||||
|     } catch (e) { | ||||
|       console.error(e); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|     async distribute(data) { | ||||
|         try { | ||||
|             const response = await http.post('/transaction/distribute').send(data); | ||||
|             return response; | ||||
|         } catch (e) { | ||||
|             console.error(e); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     async distributeAdmin(data) { | ||||
|         try { | ||||
|             const response = await http.post('/transaction/distribute-admin').send(data); | ||||
|             return response; | ||||
|         } catch (e) { | ||||
|             console.error(e); | ||||
|         } | ||||
|   async distributeAdmin(data) { | ||||
|     try { | ||||
|       const response = await http | ||||
|         .post("/transaction/distribute-admin") | ||||
|         .send(data); | ||||
|       return response; | ||||
|     } catch (e) { | ||||
|       console.error(e); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user