Merge
This commit is contained in:
67
src/store/approval.js
Normal file
67
src/store/approval.js
Normal file
@@ -0,0 +1,67 @@
|
||||
import {makeAutoObservable} from "mobx";
|
||||
import {http} from "../utils/http";
|
||||
|
||||
export class Approval {
|
||||
page = 0;
|
||||
pageSize = 10
|
||||
data = [];
|
||||
listImage=[];
|
||||
total_data = 0;
|
||||
|
||||
constructor(ctx) {
|
||||
this.ctx = ctx;
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
async getData() {
|
||||
try {
|
||||
const response = await http.get(`/users/find-by-approval?page=${this.page}&pageSize=${this.pageSize}`);
|
||||
console.log(response,"data dari store")
|
||||
this.data = response.body.data ?? []
|
||||
this.listImage= this.data.user_detail?.image_store ? JSON.parse(this.data.user_detail?.image_store) : []
|
||||
this.total_data = response.body.count ?? 0
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async approveUser(id) {
|
||||
try {
|
||||
const response = await http.put(`/users/approve-user/${id}`);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
async rejectUser(id) {
|
||||
try {
|
||||
const response = await http.put(`/users/reject-user/${id}`);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async resendUser(id) {
|
||||
try {
|
||||
const response = await http.put(`/users/resend-user/${id}`);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
// async delete(id) {
|
||||
// try {
|
||||
// const response = await http.del(`/product/${id}`);
|
||||
// await this.getData();
|
||||
// return response;
|
||||
// } catch (e) {
|
||||
// console.error(e);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,10 @@ export class Authentication {
|
||||
isLoggedIn = false;
|
||||
isLoginLoading = false;
|
||||
ctx;
|
||||
profileData = {};
|
||||
dataProfit=[];
|
||||
listImage=[];
|
||||
imageProfil=[];
|
||||
|
||||
constructor(ctx) {
|
||||
this.ctx = ctx;
|
||||
@@ -33,7 +37,7 @@ export class Authentication {
|
||||
|
||||
try {
|
||||
const result = await http.post('/auth/login').send({username, password});
|
||||
|
||||
|
||||
TokenUtil.setAccessToken(result.body.access_token);
|
||||
TokenUtil.persistToken();
|
||||
runInAction(() => {
|
||||
@@ -49,9 +53,35 @@ export class Authentication {
|
||||
}
|
||||
}
|
||||
|
||||
async getProfit(id) {
|
||||
try {
|
||||
const response = await http.get(`/auth/profile/${id}`);
|
||||
console.log(response,"Data Gambar Store")
|
||||
this.dataProfit = response.body ?? [];
|
||||
this.listImage = this.dataProfit.userDetail?.image_store ? JSON.parse(this.dataProfit.userDetail?.image_store) : [];
|
||||
this.total_data = response?.body?.count ?? 0;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getProfile() {
|
||||
try {
|
||||
const response = await http.get('/auth/profile');
|
||||
console.log(response,"Data Profile")
|
||||
this.profileData = response.body;
|
||||
this.imageProfil = this.profileData.userDetail?.image_store ? JSON.parse(this.profileData.userDetail?.image_store) : [];
|
||||
|
||||
//this.imageProfil = this.profileData.userDetail?.image_store ? JSON.parse(this.profileData.userDetail?.image_store) : [];
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
logout() {
|
||||
TokenUtil.clearAccessToken();
|
||||
TokenUtil.persistToken();
|
||||
this.isLoggedIn = false;
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
99
src/store/category.js
Normal file
99
src/store/category.js
Normal file
@@ -0,0 +1,99 @@
|
||||
import {makeAutoObservable} from "mobx";
|
||||
import {http} from "../utils/http";
|
||||
|
||||
export class Category {
|
||||
page = 0;
|
||||
pageSize = 10
|
||||
data = [];
|
||||
total_data = 0;
|
||||
filterCategory = null;
|
||||
visibleModalCategory = false;
|
||||
|
||||
pageSubCategories = 0;
|
||||
pageSizeSubCategories = 10
|
||||
dataSubCategories = [];
|
||||
total_dataSubCategories = 0;
|
||||
|
||||
constructor(ctx) {
|
||||
this.ctx = ctx;
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
async getData() {
|
||||
try {
|
||||
const response = await http.get(`/product/categories?page=${this.page}&pageSize=${this.pageSize}`);
|
||||
//console.log(response)
|
||||
this.data = response.body.data.map((item, idx) => {
|
||||
item.key = idx;
|
||||
return item
|
||||
}) ?? []
|
||||
this.total_data = response?.body?.count ?? 0
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getDataSubCategories() {
|
||||
try {
|
||||
const response = await http.get(`/product/sub-categories?page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}`);
|
||||
this.dataSubCategories = response.body.data.map((item, idx) => {
|
||||
item.key = idx;
|
||||
return item
|
||||
}) ?? []
|
||||
|
||||
this.total_dataSubCategories = response.body.count ?? 0
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getDataCategories() {
|
||||
try {
|
||||
const response = await http.get(`/product/categories?page=${this.pageCategories}&pageSize=${this.pageSizeCategories}`);
|
||||
|
||||
this.dataCategories = response.body.data.map((item, idx) => {
|
||||
item.key = idx;
|
||||
return item
|
||||
}) ?? []
|
||||
|
||||
this.total_dataCategories = response?.body?.count ?? 0
|
||||
if (this.dataCategories.length > 0) {
|
||||
this.filterCategory = this.dataCategories[0].id
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async create(data) {
|
||||
try {
|
||||
const response = await http.post('/product/categories').send(data);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id, data) {
|
||||
try {
|
||||
const response = await http.put(`/product/categories/${id}`).send(data);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async delete(id) {
|
||||
try {
|
||||
const response = await http.del(`/product/${id}`);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
62
src/store/commission.js
Normal file
62
src/store/commission.js
Normal file
@@ -0,0 +1,62 @@
|
||||
import {makeAutoObservable} from "mobx";
|
||||
import {http} from "../utils/http";
|
||||
|
||||
export class Commission {
|
||||
page = 0;
|
||||
pageSize = 10
|
||||
data = [];
|
||||
total_data = 0;
|
||||
filterCategory = null;
|
||||
visibleModalCommission = 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() {
|
||||
try {
|
||||
const response = await http.get(`/config/commission?page=${this.page}&pageSize=${this.pageSize}`);
|
||||
this.data = response.body.data.map((item, idx) => {
|
||||
item.key = idx;
|
||||
return item
|
||||
}) ?? []
|
||||
|
||||
this.total_data = response?.body?.count ?? 0
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id, data) {
|
||||
try {
|
||||
const response = await http.put(`/config/commission/${id}`).send(data);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async delete(id) {
|
||||
try {
|
||||
const response = await http.del(`/product/${id}`);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
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 { Partner } from "./partner";
|
||||
import { Supplier } from "./supplier";
|
||||
import { Commission } from "./commission";
|
||||
import { Transaction } from "./transaction";
|
||||
import { TokenUtil } from "../utils/token";
|
||||
import { Category } from "./category";
|
||||
import { Subcategory } from "./subcategory";
|
||||
import { Payback } from "./payback";
|
||||
import { Role } from "./role";
|
||||
import { Approval } from "./approval";
|
||||
|
||||
|
||||
export class Store {
|
||||
ui = new UI(this);
|
||||
@@ -12,7 +21,15 @@ export class Store {
|
||||
user = new User(this);
|
||||
membership = new Membership(this);
|
||||
product = new Product(this);
|
||||
partner = new Partner(this);
|
||||
supplier = new Supplier(this);
|
||||
commission = new Commission(this);
|
||||
category = new Category(this);
|
||||
payback = new Payback(this);
|
||||
transaction = new Transaction(this);
|
||||
subcategory = new Subcategory(this);
|
||||
role = new Role(this);
|
||||
approval = new Approval(this);
|
||||
|
||||
constructor() {
|
||||
TokenUtil.loadToken();
|
||||
|
||||
@@ -1,36 +1,135 @@
|
||||
import {action, makeAutoObservable} from "mobx";
|
||||
import {makeAutoObservable} from "mobx";
|
||||
import {http} from "../utils/http";
|
||||
|
||||
export class Membership {
|
||||
page = 0;
|
||||
pageSize = 10
|
||||
data = [];
|
||||
total_data = 0
|
||||
total_data = 0;
|
||||
dataTotal=0;
|
||||
|
||||
dataDetail = {};
|
||||
dataMember=[];
|
||||
|
||||
|
||||
//filter
|
||||
visibleModalFilterMembership = false;
|
||||
filterMembership = null;
|
||||
filterPartner = null;
|
||||
constructor(ctx) {
|
||||
this.ctx = ctx;
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
@action
|
||||
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
|
||||
try {
|
||||
const response = await http.get(`/users?page=${this.page}&pageSize=${this.pageSize}&superior=${this.filterMembership}&type=${this.filterPartner}`);
|
||||
console.log(this.filterMembership)
|
||||
// console.log(this.filterPartner)
|
||||
console.log(response)
|
||||
this.dataMember = response.body.data ?? []
|
||||
// this.dataMember = response.body.data.map((item, idx) => {
|
||||
// item.key = idx;
|
||||
// item.name = item?.user_detail?.name;
|
||||
// item.phone_number = item?.user_detail?.phone_number;
|
||||
// item.roleId = item?.roles.id;
|
||||
// item.roleName = item?.roles.name;
|
||||
// return item
|
||||
// }) ?? []
|
||||
|
||||
this.dataTotal = response?.body?.count ?? 0
|
||||
console.log(this.dataTotal)
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getDetail(id) {
|
||||
try {
|
||||
const response = await http.get(`/users/`+id);
|
||||
console.log(response,'Data Detail')
|
||||
this.dataDetail = response.body.data
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getDataBySuperior() {
|
||||
try {
|
||||
const response = await http.get(`/users/find-by-supperior?page=${this.page}&pageSize=${this.pageSize}`);
|
||||
console.log(response)
|
||||
this.data = response.body.data.map((item, idx) => {
|
||||
item.key = idx;
|
||||
item.name = item?.user_detail?.name;
|
||||
item.phone_number = item?.user_detail?.phone_number;
|
||||
item.roleId = item?.roles.id;
|
||||
item.roleName = item?.roles?.name;
|
||||
return item
|
||||
}) ?? []
|
||||
|
||||
this.total_data = response?.body?.count ?? 0
|
||||
console.log(this.total_data)
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
async create(data) {
|
||||
return await http.post('/users').send(data)
|
||||
try {
|
||||
const response = await http.post('/users').send(data);
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
async update(id, data) {
|
||||
return await http.put('/users/' + id).send(data);
|
||||
try {
|
||||
const response = await http.put('/users/' + id).send(data);
|
||||
console.log(data,"data dari store")
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async changePassword(id, data) {
|
||||
try {
|
||||
const response = await http.put('/users/change-password/' + id).send(data);
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async delete(id) {
|
||||
return await http.del('/users/' + id);
|
||||
try {
|
||||
const response = await http.del('/users/' + id);
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async changeStatus(id, status) {
|
||||
try {
|
||||
const response = await http.get(`/users/${id}/${status}`);
|
||||
console.log(status,"change status")
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async withdrawProfit(id) {
|
||||
try {
|
||||
const response = await http.put(`/transaction/withdraw/${id}`);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
91
src/store/partner.js
Normal file
91
src/store/partner.js
Normal file
@@ -0,0 +1,91 @@
|
||||
import {makeAutoObservable} from "mobx";
|
||||
import {http} from "../utils/http";
|
||||
|
||||
export class Partner {
|
||||
page = 0;
|
||||
pageSize = 10
|
||||
data = [];
|
||||
total_data = 0;
|
||||
filterCategory = null;
|
||||
visibleModalPartner = 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() {
|
||||
try {
|
||||
const response = await http.get(`/users/partner?page=${this.page}&pageSize=${this.pageSize}`);
|
||||
//console.log(response)
|
||||
this.data = response.body.data.map((item, idx) => {
|
||||
item.key = idx;
|
||||
return item
|
||||
}) ?? []
|
||||
|
||||
this.total_data = response.body.count ?? 0
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async create(data) {
|
||||
try {
|
||||
const response = await http.post('/users/partner').send(data);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id, data) {
|
||||
try {
|
||||
const response = await http.put(`/users/partner/${id}`).send(data);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async updatePassword(id, data) {
|
||||
const response = await http.put(`/users/change-password-partner/${id}`).send(data);
|
||||
console.log(response)
|
||||
await this.getData();
|
||||
return response;
|
||||
}
|
||||
|
||||
async delete(id) {
|
||||
try {
|
||||
const response = await http.del(`/product/${id}`);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async changeStatus(id, status) {
|
||||
try {
|
||||
const response = await http.get(`/users/partner/${id}/${status}`);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
125
src/store/payback.js
Normal file
125
src/store/payback.js
Normal file
@@ -0,0 +1,125 @@
|
||||
import { makeAutoObservable } from "mobx";
|
||||
import { http } from "../utils/http";
|
||||
|
||||
export class Payback {
|
||||
pageCreated = 0;
|
||||
pageSizeCreated = 10;
|
||||
dataCreated = [];
|
||||
totalDataCreated = 0;
|
||||
filterCategory = null;
|
||||
visibleModalPayback = false;
|
||||
|
||||
pageConfirmation = 0;
|
||||
pageSizeConfirmation = 10;
|
||||
dataConfirmation = [];
|
||||
totalDataConfirmation = 0;
|
||||
//data=[]
|
||||
|
||||
//filter
|
||||
visibleModalFilterPayback = false;
|
||||
filterMembership = null;
|
||||
filterStart = null;
|
||||
filterEnd = null;
|
||||
|
||||
filterStartConfirmation = null;
|
||||
filterEndConfirmation = null;
|
||||
|
||||
|
||||
//filter created
|
||||
visibleModalFilterCreate = false;
|
||||
constructor(ctx) {
|
||||
this.ctx = ctx;
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
async getDataCreated() {
|
||||
try {
|
||||
const response = await http.get(
|
||||
`/transaction/deposit-return?page=${this.pageCreated}&pageSize=${this.pageSizeCreated}&start=${this.filterStart}&end=${this.filterEnd}`
|
||||
);
|
||||
console.log(response)
|
||||
this.dataCreated =
|
||||
response.body.data.map((item, idx) => {
|
||||
item.key = idx;
|
||||
return item;
|
||||
}) ?? [];
|
||||
|
||||
this.totalDataCreated = response.body.count ?? 0;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getDataConfirmation() {
|
||||
try {
|
||||
const response = await http.get(
|
||||
`/transaction/deposit-return/confirmation?page=${this.pageConfirmation}&pageSize=${this.pageSizeConfirmation}&start=${this.filterStart}&end=${this.filterEnd}&sender=${this.filterMembership}`
|
||||
);
|
||||
console.log(response);
|
||||
this.dataConfirmation =
|
||||
response.body.data.map((item, idx) => {
|
||||
item.key = idx;
|
||||
return item;
|
||||
}) ?? [];
|
||||
|
||||
this.totalDataConfirmation = response.body.count ?? 0;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id, data) {
|
||||
try {
|
||||
const response = await http.put(`/config/commission/${id}`).send(data);
|
||||
await this.getDataCreated();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async delete(id) {
|
||||
try {
|
||||
const response = await http.del(`/product/${id}`);
|
||||
await this.getDataCreated();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async create(data) {
|
||||
try {
|
||||
const response = await http
|
||||
.post("/transaction/deposit-return")
|
||||
.send(data);
|
||||
await this.getDataCreated();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async confirmPayback(id, data) {
|
||||
try {
|
||||
const response = await http.put(
|
||||
`/transaction/deposit-return/confirmation/${id}/${data}`
|
||||
);
|
||||
// console.log(response)
|
||||
// this.data=response.body.data
|
||||
await Promise.all([this.getDataConfirmation(), this.getDataCreated()]);
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async uploadImages(data) {
|
||||
try {
|
||||
const response = await http.upload(data);
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,39 +1,170 @@
|
||||
import {action, makeAutoObservable} from "mobx";
|
||||
import {makeAutoObservable} from "mobx";
|
||||
import {http} from "../utils/http";
|
||||
|
||||
export class Product {
|
||||
page = 0;
|
||||
pageSize = 10
|
||||
data = [];
|
||||
total_data = 0
|
||||
total_data = 0;
|
||||
total_data_partner=0;
|
||||
filterSupplier = null;
|
||||
filterSubCategory = null;
|
||||
visibleModalProduct = false;
|
||||
visibleModalFilterProduct = false;
|
||||
uploadBtnProduct = false;
|
||||
|
||||
pageCategories = 0;
|
||||
pageSizeCategories = 100;
|
||||
dataCategories = [];
|
||||
total_dataCategories = 0;
|
||||
|
||||
pageSubCategories = 0;
|
||||
pageSizeSubCategories = 10
|
||||
dataSubCategories = [];
|
||||
total_dataSubCategories = 0;
|
||||
filterCategory = null;
|
||||
|
||||
dataPriceHistory = [];
|
||||
totalDataPriceHistory = 0;
|
||||
pagePriceHistory = 0;
|
||||
pageProductPartner = 0;
|
||||
pageSizePriceHistory = 10
|
||||
|
||||
dataDetailProduct = {};
|
||||
dataProductPartner=[]
|
||||
|
||||
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
|
||||
try {
|
||||
const response = await http.get(`/product/all?supplier=${this.filterSupplier}&sub-category=${this.filterSubCategory}&page=${this.page}&pageSize=${this.pageSize}`);
|
||||
console.log(response)
|
||||
this.data = response.body.data.map((item, idx) => {
|
||||
item.key = idx;
|
||||
return item
|
||||
}) ?? []
|
||||
|
||||
this.total_data = response?.body?.count ?? 0
|
||||
//console.log(this.total_data)
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getDataSubCategories() {
|
||||
try {
|
||||
const response = await http.get(`/product/sub-categories?category=${this.filterCategory}&page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}`);
|
||||
this.dataSubCategories = response.body.data.map((item, idx) => {
|
||||
item.key = idx;
|
||||
return item
|
||||
}) ?? []
|
||||
this.total_dataSubCategories = response.body.count ?? 0
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getDataCategories() {
|
||||
try {
|
||||
const response = await http.get(`/product/categories?page=${this.pageCategories}&pageSize=${this.pageSizeCategories}`);
|
||||
this.dataCategories = response.body.data.map((item, idx) => {
|
||||
item.key = idx;
|
||||
return item
|
||||
}) ?? []
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getPriceHistoryByProduct(id) {
|
||||
try {
|
||||
const response = await http.get(`/product/price-history/${id}?page=${this.pagePriceHistory}&pageSize${this.pageSizePriceHistory}`);
|
||||
this.dataPriceHistory = response.body.data
|
||||
this.totalDataPriceHistory = response?.body?.count ?? 0
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getDetailProduct(id) {
|
||||
try {
|
||||
const response = await http.get(`/product/${id}`);
|
||||
this.dataDetailProduct = response.body.data
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getProductPartner(id) {
|
||||
try {
|
||||
const response = await http.get(`/product/by-categories?page=${this.pageProductPartner}&pageSize=10&sub-category=${id}`);
|
||||
console.log(response)
|
||||
this.dataProductPartner = response.body.data
|
||||
this.total_data_partner= response?.body?.count ?? 0
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
async create(data) {
|
||||
return await http.post('/product').send(data)
|
||||
try {
|
||||
const response = await http.post('/product').send(data);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
async buyProduct(data) {
|
||||
try {
|
||||
const response = await http.post('/transaction/order').send(data);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
async update(id, data) {
|
||||
return await http.put('/user/' + id).send(data);
|
||||
try {
|
||||
const response = await http.put(`/product/${id}`).send(data);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async delete(id) {
|
||||
return await http.del('/product/' + id);
|
||||
try {
|
||||
const response = await http.del(`/product/${id}`);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async uploadExcel(data) {
|
||||
try {
|
||||
const response = await http.upload(data);
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async uploadProduct(data) {
|
||||
try {
|
||||
const response = await http.post('/product/upload-product').send(data);
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,33 +2,51 @@ import {makeAutoObservable} from "mobx";
|
||||
import {http} from "../utils/http";
|
||||
|
||||
export class Role {
|
||||
page = null;
|
||||
pageSize = null;
|
||||
data = [];
|
||||
total_data = 0
|
||||
page = 0;
|
||||
pageSize = 10;
|
||||
data = [];
|
||||
total_data = 0;
|
||||
|
||||
constructor(ctx) {
|
||||
this.ctx = ctx;
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
constructor(ctx) {
|
||||
this.ctx = ctx;
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
async getData() {
|
||||
const response = await http.get(`/config/roles?page=${this.page}&pageSize=${this.pageSize}`);
|
||||
this.data = response.body.data ?? []
|
||||
this.total_data = response.body.total_data ?? 0
|
||||
async getData(isForMembership = false) {
|
||||
try {
|
||||
const response = await http.get(
|
||||
`/config/roles${isForMembership ? "/for-membership" : ""}?page=${
|
||||
this.page
|
||||
}&pageSize=${this.pageSize}`
|
||||
);
|
||||
this.data = response.body.data ?? [];
|
||||
this.total_data = response?.body?.count ?? 0;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async create(data) {
|
||||
return await http.post('/users').send(data)
|
||||
async create(data) {
|
||||
try {
|
||||
return await http.post("/users").send(data);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id, data) {
|
||||
return await http.put('/users/' + id).send(data);
|
||||
async update(id, data) {
|
||||
try {
|
||||
return await http.put("/users/" + id).send(data);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async delete(id) {
|
||||
return await http.del('/users/' + id);
|
||||
async delete(id) {
|
||||
try {
|
||||
return await http.del("/users/" + id);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
88
src/store/subcategory.js
Normal file
88
src/store/subcategory.js
Normal file
@@ -0,0 +1,88 @@
|
||||
import {makeAutoObservable} from "mobx";
|
||||
import {http} from "../utils/http";
|
||||
|
||||
export class Subcategory {
|
||||
page = 0;
|
||||
pageSize = 10
|
||||
data = [];
|
||||
total_data = 0;
|
||||
filterCategory = null;
|
||||
visibleModalSubcategory = 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() {
|
||||
try {
|
||||
const response = await http.get(`/product/sub-categories?page=${this.page}&pageSize=${this.pageSize}`);
|
||||
console.log(response)
|
||||
this.data = response.body.data.map((item, idx) => {
|
||||
item.key = idx;
|
||||
item.categoryName = item.category.name;
|
||||
return item
|
||||
}) ?? []
|
||||
|
||||
this.total_data = response?.body?.count ?? 0
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getDataSubCategories() {
|
||||
try {
|
||||
const response = await http.get(`/product/sub-categories?page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}`);
|
||||
this.dataSubCategories = response.body.data.map((item, idx) => {
|
||||
item.key = idx;
|
||||
return item
|
||||
}) ?? []
|
||||
|
||||
this.total_dataSubCategories = response.body.count ?? 0
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async create(data) {
|
||||
try {
|
||||
const response = await http.post('/product/sub-categories').send(data);
|
||||
//await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id, data) {
|
||||
try {
|
||||
const response = await http.put(`/product/sub-categories/${id}`).send(data);
|
||||
//await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async delete(id) {
|
||||
try {
|
||||
const response = await http.del(`/product/${id}`);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
87
src/store/supplier.js
Normal file
87
src/store/supplier.js
Normal file
@@ -0,0 +1,87 @@
|
||||
import { makeAutoObservable } from "mobx";
|
||||
import { http } from "../utils/http";
|
||||
|
||||
export class Supplier {
|
||||
page = 0;
|
||||
pageSize = 10;
|
||||
data = [];
|
||||
total_data = 0;
|
||||
filterCategory = null;
|
||||
visibleModalSupplier = false;
|
||||
visibleModalTransaction = false;
|
||||
code = "";
|
||||
|
||||
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() {
|
||||
try {
|
||||
const response = await http.get(
|
||||
`/users/supplier?page=${this.page}&pageSize=${this.pageSize}`
|
||||
);
|
||||
//console.log(response)
|
||||
this.data = response.body.data ?? [];
|
||||
this.total_data = response.body.count ?? 0;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async create(data) {
|
||||
const response = await http.post("/users/supplier").send(data);
|
||||
return response;
|
||||
}
|
||||
async createTransaction(data) {
|
||||
try {
|
||||
const response = await http
|
||||
.post("/transaction/add-saldo-supplier")
|
||||
.send(data);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id, data) {
|
||||
try {
|
||||
const response = await http.put(`/users/supplier/${id}`).send(data);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async delete(id) {
|
||||
try {
|
||||
const response = await http.del(`/product/${id}`);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async changeStatus(id, status) {
|
||||
try {
|
||||
const response = await http.get(`/users/supplier/${id}/${status}`);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
229
src/store/transaction.js
Normal file
229
src/store/transaction.js
Normal file
@@ -0,0 +1,229 @@
|
||||
import { makeAutoObservable } from "mobx";
|
||||
import { http } from "../utils/http";
|
||||
|
||||
export class Transaction {
|
||||
page = 0;
|
||||
pageSize = 10;
|
||||
data = [];
|
||||
total_data = 0;
|
||||
|
||||
|
||||
filterSubCategory = null;
|
||||
visibleModalProduct = false;
|
||||
visibleModalTransaction = false;
|
||||
pageSizeDetail=10;
|
||||
pageDetail=0
|
||||
|
||||
pageCategories = 0;
|
||||
pageSizeCategories = 10;
|
||||
dataCategories = [];
|
||||
total_dataCategories = 0;
|
||||
|
||||
pageSubCategories = 0;
|
||||
pageSizeSubCategories = 10;
|
||||
dataSubCategories = [];
|
||||
total_dataSubCategories = 0;
|
||||
filterSubCategory = null;
|
||||
|
||||
pageHistoryTransaction = 0;
|
||||
pageSizeHistoryTransaction = 10;
|
||||
dataHistoryTransaction = [];
|
||||
total_dataHistoryTransaction = 0;
|
||||
|
||||
pageHistoryTransactionDetailUser = 0;
|
||||
pageSizeHistoryTransactionDetailUser = 10;
|
||||
dataHistoryTransactionDetailUser = [];
|
||||
total_dataHistoryTransactionDetailUser = 0;
|
||||
|
||||
pageHistoryTopUp = 0;
|
||||
pageSizeHistoryTopUp = 10;
|
||||
dataHistoryTopUp = [];
|
||||
total_dataHistoryTopUp = 0;
|
||||
|
||||
dataTransaction = [];
|
||||
dataTransactionB2B = [];
|
||||
dataTransactionPartner = [];
|
||||
total_dataDetailHistoryTransactionDetailUser=0;
|
||||
|
||||
|
||||
//filter
|
||||
visibleModalFilterTransaction = false;
|
||||
filterStart = null;
|
||||
filterEnd = null;
|
||||
filterStartDetailUser = null;
|
||||
filterEndDetailUser = null;
|
||||
constructor(ctx) {
|
||||
this.ctx = ctx;
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
|
||||
async getData() {
|
||||
try {
|
||||
const response = await http.get(
|
||||
`/product/by-categories-all?sub-category=${this.filterSubCategory}&page=${this.page}&pageSize=${this.pageSize}`
|
||||
);
|
||||
this.data = response.body.data ?? [];
|
||||
this.total_data = response?.body?.count ?? 0;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getDataTransaction() {
|
||||
try {
|
||||
const response = await http.get(`/transaction/total-order`);
|
||||
//console.log(response)
|
||||
this.dataTransaction = response.body.data;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getDataTransactionB2B() {
|
||||
try {
|
||||
const response = await http.get(`/transaction/total-order-b2b`);
|
||||
//console.log(response)
|
||||
this.dataTransactionB2B = response.body.data;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getDataTransactionPartner() {
|
||||
try {
|
||||
const response = await http.get(`/transaction/total-order-partner`);
|
||||
//console.log(response)
|
||||
this.dataTransactionPartner = response.body.data;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getDataSubCategories() {
|
||||
try {
|
||||
const response = await http.get(
|
||||
`/product/sub-categories?category=${this.filterCategory}&page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}`
|
||||
);
|
||||
this.dataSubCategories = response.body.data ?? [];
|
||||
this.total_dataSubCategories = response.body.count ?? 0;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getDataCategories() {
|
||||
try {
|
||||
const response = await http.get(
|
||||
`/product/categories?page=${this.pageCategories}&pageSize=${this.pageSizeCategories}`
|
||||
);
|
||||
this.dataCategories = response.body.data ?? [];
|
||||
this.total_dataCategories = response?.body?.count ?? 0;
|
||||
if (this.dataCategories.length > 0) {
|
||||
this.filterCategory = this.dataCategories[0].id;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getDataHistoryTransaction() {
|
||||
try {
|
||||
const response = await http.get(
|
||||
`/transaction/history?page=${this.pageHistoryTransaction}&pageSize=${this.pageSizeHistoryTransaction}&start=${this.filterStart}&end=${this.filterEnd}`
|
||||
);
|
||||
console.log(response);
|
||||
this.dataHistoryTransaction = response.body.data ?? [];
|
||||
this.total_dataHistoryTransaction = response?.body?.count ?? 0;
|
||||
console.log(this.total_dataHistoryTransaction)
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getDetailHistoryTransaction(id) {
|
||||
try {
|
||||
const response = await http.get(`/transaction/history-user/${id}?page=${this.page}&pageSize=${this.pageSize}&start=${this.filterStart}&end=${this.filterEnd}`);
|
||||
console.log(response,'Data Trans');
|
||||
this.dataDetailHistoryTransactionDetailUser = response.body.data ?? [];
|
||||
this.total_data = response?.body?.count ?? 0;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async getDataHistoryTopUp(id) {
|
||||
try {
|
||||
const response = await http.get(
|
||||
`/transaction/history-deposit?page=${this.pageHistoryTopUp}&pageSize=${this.pageSizeHistoryTopUp}&user-destination=${id}`
|
||||
);
|
||||
console.log(response,'get data history')
|
||||
this.dataHistoryTopUp = response.body.data ?? [];
|
||||
this.total_dataHistoryTopUp = response?.body?.count ?? 0;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async create(data) {
|
||||
try {
|
||||
const response = await http.post("/product").send(data);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async buyProduct(data) {
|
||||
const response = await http.post("/transaction/order").send(data);
|
||||
console.log(response,'dari store')
|
||||
return response;
|
||||
}
|
||||
|
||||
async buyProd(data) {
|
||||
const response = await http.post("/transaction/order-prod").send(data);
|
||||
console.log(response)
|
||||
return response;
|
||||
}
|
||||
|
||||
async update(id, data) {
|
||||
try {
|
||||
const response = await http.put(`/product/${id}`).send(data);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async delete(id) {
|
||||
try {
|
||||
const response = await http.del(`/product/${id}`);
|
||||
await this.getData();
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async distribute(data) {
|
||||
try {
|
||||
const response = await http.post("/transaction/distribute").send(data);
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async distributeAdmin(data) {
|
||||
try {
|
||||
const response = await http
|
||||
.post("/transaction/distribute-admin")
|
||||
.send(data);
|
||||
return response;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ export class UI {
|
||||
}
|
||||
|
||||
setTestValue() {
|
||||
this.testValue = "yo dayo";
|
||||
this.testValue = "yoshahhh #!";
|
||||
}
|
||||
|
||||
setMediaQuery(data) {
|
||||
@@ -23,7 +23,7 @@ export class UI {
|
||||
};
|
||||
|
||||
toggleLeftDrawerIsShown() {
|
||||
console.log('what')
|
||||
//console.log('what')
|
||||
this.leftDrawerIsShown = !this.leftDrawerIsShown;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
import {action, observable} from "mobx";
|
||||
import {makeAutoObservable} from "mobx";
|
||||
import {http} from "../utils/http";
|
||||
|
||||
export class User {
|
||||
@observable data = [];
|
||||
data = [];
|
||||
|
||||
constructor(ctx) {
|
||||
this.ctx = ctx;
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
@action
|
||||
async getData() {
|
||||
this.data = (await http.get('/product')).body.data;
|
||||
try {
|
||||
this.data = (await http.get('/user')).body.data;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user