41 lines
917 B
JavaScript
41 lines
917 B
JavaScript
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);
|
|
}
|
|
}
|
|
|
|
|