Page Category

This commit is contained in:
2021-12-15 14:41:00 +07:00
parent 324dd47709
commit 7b95d2901b
16 changed files with 644 additions and 172 deletions

69
src/store/category.js Normal file
View File

@@ -0,0 +1,69 @@
import {makeAutoObservable} from "mobx";
import {http} from "../utils/http";
export class Category {
page = 0;
pageSize = 10
data = [];
total_data = 0;
filterCategory = null;
visibleModalCategory = 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(`/product/categories?page=${this.page}&pageSize=${this.pageSize}`);
console.log(response)
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
}
}
async create(data) {
const response = await http.post('/product/categories').send(data);
await this.getData();
return response;
}
async update(id, data) {
const response = await http.put(`/product/categories/${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

@@ -8,6 +8,8 @@ import { Supplier } from "./supplier";
import { Commission } from "./commission";
import { Transaction } from "./transaction";
import { TokenUtil } from "../utils/token";
import { Category } from "./category";
import { Role } from "./role";
export class Store {
@@ -19,6 +21,7 @@ export class Store {
partner = new Partner(this);
supplier = new Supplier(this);
commission = new Commission(this);
category = new Category(this);
transaction = new Transaction(this);
role = new Role(this);

View File

@@ -14,10 +14,16 @@ export class Membership {
@action
async getData() {
const response = await http.get(`/users/find-by-supperior?page=${this.page}&pageSize=${this.pageSize}`);
const response = await http.get(`/users?page=${this.page}&pageSize=${this.pageSize}`);
console.log(response)
this.data = response.body.data ?? []
this.total_data = response.body.total_data ?? 0
}
// async getData() {
// const response = await http.get(`/users/find-by-supperior?page=${this.page}&pageSize=${this.pageSize}`);
// this.data = response.body.data ?? []
// this.total_data = response.body.total_data ?? 0
// }
@action
async create(data) {

0
src/store/subcategory.js Normal file
View File

View File

@@ -8,6 +8,7 @@ export class Supplier {
total_data = 0;
filterCategory = null;
visibleModalSupplier = false;
visibleModalTransaction=false;
pageCategories = 0;
pageSizeCategories = 10
@@ -36,9 +37,14 @@ export class Supplier {
await this.getData();
return response;
}
async createTransaction(data) {
const response = await http.post('/transaction/add-saldo-supplier').send(data);
await this.getData();
return response;
}
async update(id, data) {
const response = await http.put(`/product/${id}`).send(data);
const response = await http.put(`/users/supplier/${id}`).send(data);
await this.getData();
return response;
}