fix: merge ajat

This commit is contained in:
2021-12-09 20:04:37 +07:00
committed by caturbgs
parent 525d5534df
commit 7b6784709e
8 changed files with 434 additions and 62 deletions

40
src/store/categories.js Normal file
View File

@@ -0,0 +1,40 @@
import {action, makeAutoObservable} from "mobx";
import {http} from "../utils/http";
export class Categories {
page = 0;
pageSize = 10
data = [];
total_data = 0
constructor(ctx) {
this.ctx = ctx;
makeAutoObservable(this);
}
@action
async getData() {
const response = await http.get(`/product/sub-categories?page=${this.page}&pageSize=${this.pageSize}`);
console.log(response, 'Data cate')
console.log(JSON.stringify(response.body.data), 'Data')
this.data = response.body.data ?? []
this.total_data = response.body.total_data ?? 0
}
@action
async create(data) {
return await http.post('/user').send(data)
}
@action
async update(id, data) {
return await http.put('/user/' + id).send(data);
}
async delete(id) {
return await http.del('/product/' + id);
}
}

View File

@@ -2,12 +2,16 @@ import {UI} from "./ui";
import {Authentication} from "./authentication";
import {User} from "./user";
import {Membership} from "./membership";
import {Product} from "./product";
import {Categories} from "./categories";
export class Store {
ui = new UI(this);
authentication = new Authentication(this);
user = new User(this);
membership = new Membership(this);
product = new Product(this);
categories = new Categories(this);
constructor() {
}

40
src/store/product.js Normal file
View File

@@ -0,0 +1,40 @@
import {action, makeAutoObservable} from "mobx";
import {http} from "../utils/http";
export class Product {
page = 0;
pageSize = 10
data = [];
total_data = 0
constructor(ctx) {
this.ctx = ctx;
makeAutoObservable(this);
}
@action
async getData() {
const response = await http.get(`/product?page=${this.page}&pageSize=${this.pageSize}`);
console.log(response, 'Data')
console.log(JSON.stringify(response.body.data), 'Data')
this.data = response.body.data ?? []
this.total_data = response.body.total_data ?? 0
}
@action
async create(data) {
return await http.post('/product').send(data)
}
@action
async update(id, data) {
return await http.put('/user/' + id).send(data);
}
async delete(id) {
return await http.del('/product/' + id);
}
}

View File

@@ -6,7 +6,7 @@ export class User {
@action
async getData() {
this.data = (await http.get('/user')).body.data;
this.data = (await http.get('/product')).body.data;
}
}