This commit is contained in:
2021-12-16 16:11:57 +07:00
13 changed files with 359 additions and 207 deletions

View File

@@ -6,6 +6,7 @@ export class Authentication {
isLoggedIn = false;
isLoginLoading = false;
ctx;
profileData = {};
constructor(ctx) {
this.ctx = ctx;
@@ -49,6 +50,16 @@ export class Authentication {
}
}
async getProfile() {
try {
const response = await http.get('/auth/profile');
this.profileData = response.body;
} catch (e) {
console.error(e);
throw e;
}
}
logout() {
TokenUtil.clearAccessToken();
TokenUtil.persistToken();

View File

@@ -26,8 +26,11 @@ export class Commission {
async getData() {
const response = await http.get(`/config/commission?page=${this.page}&pageSize=${this.pageSize}`);
console.log(response)
this.data = response.body.data ?? []
this.data = response.body.data.map((item, idx) => {
item.key = idx;
return item
}) ?? []
this.total_data = response.body.total_data ?? 0
}
async create(data) {

View File

@@ -14,19 +14,26 @@ export class Membership {
async getData() {
const response = await http.get(`/users?page=${this.page}&pageSize=${this.pageSize}`);
this.data = response.body.data.map((item, idx) => {
item.key = idx;
item.roleName = item.roles.name;
return item
}) ?? []
this.total_data = response.body.total_data ?? 0
}
async getDataBySuperior() {
const response = await http.get(`/users/find-by-supperior?page=${this.page}&pageSize=${this.pageSize}`);
this.data = response.body.data.map((item, idx) => {
item.key = idx;
item.roleName = item.roles.name;
return item
}) ?? []
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
// }
async create(data) {
return await http.post('/users').send(data)
@@ -47,6 +54,8 @@ export class Membership {
}
async changeStatus(id, status) {
console.log(`/users/${id}/${status}`);
const response = await http.get(`/users/${id}/${status}`);
await this.getData();
return response;

View File

@@ -1,5 +1,5 @@
import { makeAutoObservable } from "mobx";
import { http } from "../utils/http";
import {makeAutoObservable} from "mobx";
import {http} from "../utils/http";
export class Transaction {
page = 0;
@@ -19,6 +19,11 @@ export class Transaction {
dataSubCategories = [];
total_dataSubCategories = 0;
pageHistoryTransaction = 0;
// pageSizeHistoryTransaction = 10
dataHistoryTransaction = [];
total_dataHistoryTransaction = 0;
constructor(ctx) {
this.ctx = ctx;
makeAutoObservable(this);
@@ -47,6 +52,13 @@ export class Transaction {
}
}
async getDataHistoryTransaction() {
const response = await http.get(`/transaction/history?page=${this.pageHistoryTransaction}`);
this.dataHistoryTransaction = response.body.data ?? []
this.total_dataHistoryTransaction = response.body.total_data ?? 0
}
async create(data) {
const response = await http.post('/product').send(data);
await this.getData();

View File

@@ -1,9 +1,14 @@
import {action, observable} from "mobx";
import {action, makeAutoObservable, observable} from "mobx";
import {http} from "../utils/http";
export class User {
@observable data = [];
constructor(ctx) {
this.ctx = ctx;
makeAutoObservable(this);
}
@action
async getData() {
this.data = (await http.get('/user')).body.data;