From 48bc4f20f853629004be7f1c4286b7725db31e31 Mon Sep 17 00:00:00 2001 From: Hossein Date: Tue, 16 Jan 2024 17:01:55 +0330 Subject: [PATCH 1/2] #20: Add walletData api & main component --- src/Opex.js | 3 + src/components/SideBar/SideBar.js | 8 ++- src/components/TopBar/Title/Title.js | 2 + src/pages/Wallet/Wallet.js | 84 ++++++++++++++++++++++++++++ src/pages/Wallet/Wallet.module.css | 0 src/pages/Wallet/walletList.js | 57 +++++++++++++++++++ src/query/hooks/useGetWalletData.js | 14 +++++ src/query/index.js | 3 +- src/routes/routes.js | 1 + yarn.lock | 4 +- 10 files changed, 172 insertions(+), 4 deletions(-) create mode 100644 src/pages/Wallet/Wallet.js create mode 100644 src/pages/Wallet/Wallet.module.css create mode 100644 src/pages/Wallet/walletList.js create mode 100644 src/query/hooks/useGetWalletData.js diff --git a/src/Opex.js b/src/Opex.js index e56efb0..d1b5748 100644 --- a/src/Opex.js +++ b/src/Opex.js @@ -18,6 +18,8 @@ import jwt_decode from "jwt-decode"; import {getTokenByRefreshToken} from "js-api-client"; import setupAxios from "./setupAxios"; import WhiteList from "./pages/WhiteList/WhiteList"; +import Wallet from "./pages/Wallet/Wallet"; + function Opex() { const {auth, setAuth} = useAuth(); @@ -72,6 +74,7 @@ function Opex() { }/> }/> }/> + }/> }/> diff --git a/src/components/SideBar/SideBar.js b/src/components/SideBar/SideBar.js index a7d1218..de356de 100644 --- a/src/components/SideBar/SideBar.js +++ b/src/components/SideBar/SideBar.js @@ -2,7 +2,7 @@ import {toAbsoluteUrl} from "../utils"; import {NavLink} from "react-router-dom"; import * as Routes from "../../routes/routes"; import Icon from "../Icon/Icon"; -import {WhiteList} from "../../routes/routes"; +import {Wallet, WhiteList} from "../../routes/routes"; const SideBar = ({closeMenu}) => { return
@@ -42,6 +42,12 @@ const SideBar = ({closeMenu}) => { White List +
  • + + + Wallet + +
  • diff --git a/src/components/TopBar/Title/Title.js b/src/components/TopBar/Title/Title.js index 70ba3e2..770886f 100644 --- a/src/components/TopBar/Title/Title.js +++ b/src/components/TopBar/Title/Title.js @@ -2,6 +2,7 @@ import React from "react"; import {Route, Routes} from "react-router-dom"; import * as RoutesName from "../../../routes/routes"; import WhiteList from "../../../pages/WhiteList/WhiteList"; +import {Wallet} from "../../../routes/routes"; const Title = () => { @@ -14,6 +15,7 @@ const Title = () => { + ); }; diff --git a/src/pages/Wallet/Wallet.js b/src/pages/Wallet/Wallet.js new file mode 100644 index 0000000..cec20e1 --- /dev/null +++ b/src/pages/Wallet/Wallet.js @@ -0,0 +1,84 @@ +import React, {useState} from 'react'; +import {useGetWalletData} from "../../query"; +import Loading from "../../components/Loading"; +import ScrollBar from "../../components/ScrollBar"; + +const Wallet = () => { + + const [params, setParams] = useState({ + "limit": 500, + "offset": 0 + }); + + const {data, isLoading, error, refetch} = useGetWalletData(params); + + + + /*const content = () => { + if (isLoading) return
    + if (error) return
    Error
    + if (data?.length === 0) return
    No Data...!
    + + + else return <> + + + }*/ + + + return ( + +
    + + + + + + + + + + + + { + isLoading ? + + + + : data?.length === 0 ? + + + : + data?.map((wallet, index) => + + + + + + + + ) + } + +
    + NameEmailWallet TypeBalanceCurrency
    + +
    No User Exist
    {index + 1}{wallet?.title?.slice(wallet?.title.indexOf("-") +1, wallet?.title?.end) }{wallet?.title?.slice(0, wallet?.title.indexOf("-"))}{wallet?.walletType}{wallet?.balance?.toLocaleString()}{wallet?.currency}
    + {error ? +
    +