stitching pulsa component

This commit is contained in:
2021-12-10 16:32:38 +07:00
parent c8faca652d
commit cae14036db
3 changed files with 149 additions and 81 deletions

View File

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

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

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