Pages Membership

This commit is contained in:
2021-12-10 14:55:24 +07:00
9 changed files with 122 additions and 86 deletions

View File

@@ -4,6 +4,7 @@ import {User} from "./user";
import {Membership} from "./membership";
import {Product} from "./product";
import {TokenUtil} from "../utils/token";
import {Role} from "./role";
export class Store {
ui = new UI(this);
@@ -11,6 +12,7 @@ export class Store {
user = new User(this);
membership = new Membership(this);
product = new Product(this);
role = new Role(this);
constructor() {
TokenUtil.loadToken();

View File

@@ -15,8 +15,6 @@ export class Membership {
@action
async getData() {
const response = await http.get(`/users/find-by-supperior?page=${this.page}&pageSize=${this.pageSize}`);
// console.log(response, 'Data user')
// console.log(JSON.stringify(response.body.data), 'Data')
this.data = response.body.data ?? []
this.total_data = response.body.total_data ?? 0
}

View File

@@ -1,4 +1,4 @@
import {action, makeAutoObservable} from "mobx";
import {makeAutoObservable} from "mobx";
import {http} from "../utils/http";
export class Product {
@@ -7,6 +7,7 @@ export class Product {
data = [];
total_data = 0;
filterCategory = null;
visibleModalProduct = false;
pageCategories = 0;
pageSizeCategories = 10
@@ -46,15 +47,14 @@ export class Product {
}
}
@action
async create(data) {
const response = await http.post('/product', data);
const response = await http.post('/product').send(data);
await this.getData();
return response;
}
async update(id, data) {
const response = await http.put(`/product/${id}`, data);
const response = await http.put(`/product/${id}`).send(data);
await this.getData();
return response;
}

34
src/store/role.js Normal file
View File

@@ -0,0 +1,34 @@
import {makeAutoObservable} from "mobx";
import {http} from "../utils/http";
export class Role {
page = null;
pageSize = null;
data = [];
total_data = 0
constructor(ctx) {
this.ctx = ctx;
makeAutoObservable(this);
}
async getData() {
const response = await http.get(`/config/roles?page=${this.page}&pageSize=${this.pageSize}`);
this.data = response.body.data ?? []
this.total_data = response.body.total_data ?? 0
}
async create(data) {
return await http.post('/users').send(data)
}
async update(id, data) {
return await http.put('/users/' + id).send(data);
}
async delete(id) {
return await http.del('/users/' + id);
}
}