feat: stiching api profile and history transaction.js
This commit is contained in:
@@ -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.data;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
logout() {
|
||||
TokenUtil.clearAccessToken();
|
||||
TokenUtil.persistToken();
|
||||
|
||||
@@ -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}&pageSize=${this.pageSizeHistoryTransaction}`);
|
||||
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user