Pages Config

This commit is contained in:
2021-12-14 18:52:42 +07:00
parent f5903db03e
commit 558ca2a098
18 changed files with 421 additions and 342 deletions

View File

52
src/store/commission.js Normal file
View File

@@ -0,0 +1,52 @@
import {makeAutoObservable} from "mobx";
import {http} from "../utils/http";
export class Commission {
page = 0;
pageSize = 10
data = [];
total_data = 0;
filterCategory = null;
visibleModalSupplier = false;
pageCategories = 0;
pageSizeCategories = 10
dataCategories = [];
total_dataCategories = 0;
pageSubCategories = 0;
pageSizeSubCategories = 10
dataSubCategories = [];
total_dataSubCategories = 0;
constructor(ctx) {
this.ctx = ctx;
makeAutoObservable(this);
}
async getData() {
const response = await http.get(`/config/commission?page=${this.page}&pageSize=${this.pageSize}`);
console.log(response)
this.data = response.body.data ?? []
this.total_data = response.body.total_data ?? 0
}
async create(data) {
const response = await http.post('/users/supplier').send(data);
await this.getData();
return response;
}
async update(id, data) {
const response = await http.put(`/product/${id}`).send(data);
await this.getData();
return response;
}
async delete(id) {
const response = await http.del(`/product/${id}`);
await this.getData();
return response;
}
}

View File

@@ -5,7 +5,7 @@ import { Membership } from "./membership";
import { Product } from "./product";
import { Partner } from "./partner";
import { Supplier } from "./supplier";
//import { Commision } from "./commision";
import { Commission } from "./commission";
import { Transaction } from "./transaction";
import { TokenUtil } from "../utils/token";
import { Role } from "./role";
@@ -18,7 +18,7 @@ export class Store {
product = new Product(this);
partner = new Partner(this);
supplier = new Supplier(this);
//commision = new Commision(this);
commission = new Commission(this);
transaction = new Transaction(this);
role = new Role(this);

View File

@@ -25,26 +25,10 @@ export class Partner {
}
async getData() {
const response = await http.get(`/users/partner?page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}`);
const response = await http.get(`/users/partner?page=${this.page}&pageSize=${this.pageSize}`);
this.data = response.body.data ?? []
this.total_data = response.body.total_data ?? 0
}
async getDataSubCategories() {
const response = await http.get(`/product/sub-categories?page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}`);
this.dataSubCategories = response.body.data ?? []
this.total_dataSubCategories = response.body.count ?? 0
}
async getDataCategories() {
const response = await http.get(`/product/categories?page=${this.pageCategories}&pageSize=${this.pageSizeCategories}`);
this.dataCategories = response.body.data ?? []
this.total_dataCategories = response.body.total_data ?? 0
if (this.dataCategories.length > 0) {
this.filterCategory = this.dataCategories[0].id
}
//console.log(response.body,"ini dari store")
this.total_data = response.body.count ?? 0
}
async create(data) {
@@ -54,16 +38,24 @@ export class Partner {
}
async update(id, data) {
const response = await http.put(`/product/${id}`).send(data);
const response = await http.put(`/users/partner/${id}`).send(data);
await this.getData();
return response;
}
// async updateStatus(id, data) {
// const response = await http.put(`/users/partner/${id}`).send(data);
// await this.getData();
// return response;
// }
async delete(id) {
const response = await http.del(`/product/${id}`);
await this.getData();
return response;
}
}

View File

@@ -25,28 +25,12 @@ export class Supplier {
}
async getData() {
const response = await http.get(`/users/supplier?page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}`);
const response = await http.get(`/users/supplier?page=${this.page}&pageSize=${this.pageSize}`);
//console.log(response)
this.data = response.body.data ?? []
this.total_data = response.body.total_data ?? 0
this.total_data = response.body.count ?? 0
}
async getDataSubCategories() {
const response = await http.get(`/product/sub-categories?page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}`);
this.dataSubCategories = response.body.data ?? []
this.total_dataSubCategories = response.body.count ?? 0
}
async getDataCategories() {
const response = await http.get(`/product/categories?page=${this.pageCategories}&pageSize=${this.pageSizeCategories}`);
this.dataCategories = response.body.data ?? []
this.total_dataCategories = response.body.total_data ?? 0
if (this.dataCategories.length > 0) {
this.filterCategory = this.dataCategories[0].id
}
}
async create(data) {
const response = await http.post('/users/supplier').send(data);
await this.getData();