diff --git a/src/pages/Profile/Profile.js b/src/pages/Profile/Profile.js index 25e83d2..5f39827 100644 --- a/src/pages/Profile/Profile.js +++ b/src/pages/Profile/Profile.js @@ -1,12 +1,13 @@ -import React from "react"; -import {Card, Col, Row, Typography} from "antd"; +import React, {useEffect} from "react"; +import {Card, Col, Row, Table, Typography} from "antd"; import {BreadcumbComponent} from "../../component/BreadcumbComponent"; import {LINKS} from "../../routes/app"; import {useStore} from "../../utils/useStore"; +import {observer} from "mobx-react-lite"; const {Title, Text} = Typography; -export const Profile = () => { +export const Profile = observer(() => { const store = useStore(); const routeData = [ { @@ -19,6 +20,35 @@ export const Profile = () => { }, ]; + useEffect(() => { + (async () => { + await Promise.allSettled([ + store.authentication.getProfile(), + store.transaction.getDataHistoryTransaction(), + ]); + })() + }, []); + + const columns = [ + { + title: 'Markup Price', + dataIndex: 'mark_up_price', + key: 'mark_up_price', + width: '20%', + }, + { + title: 'Name', + dataIndex: 'name', + key: 'name', + width: '50%', + }, + { + title: 'Transaction Date', + dataIndex: 'created_at', + key: 'created_at', + }, + ] + return (
@@ -27,26 +57,49 @@ export const Profile = () => {
Profile - - - Name - - - {store.authentication.userData.username} - - - Role - - - {store.authentication.userData.role} - - + {/**/} + {/* */} + {/* Name*/} + {/* */} + {/* */} + {/* {store.authentication.profileData.username}*/} + {/* */} + {/* */} + {/* Role*/} + {/* */} + {/* */} + {/* {store.authentication.profileData.roles.name}*/} + {/* */} + {/* */} + {/* Superior*/} + {/* */} + {/* */} + {/* {store.authentication.profileData.superior.username}*/} + {/* */} + {/* */} + {/* Wallet*/} + {/* */} + {/* */} + {/* {store.authentication.profileData.wallet}*/} + {/* */} + {/**/} +
+ + + + +
+ History User Transaction +
-
) -}; +}); diff --git a/src/store/authentication.js b/src/store/authentication.js index 4b90963..526f512 100644 --- a/src/store/authentication.js +++ b/src/store/authentication.js @@ -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(); diff --git a/src/store/transaction.js b/src/store/transaction.js index 8150f40..50cd379 100644 --- a/src/store/transaction.js +++ b/src/store/transaction.js @@ -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();