add data request straking dashboard
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { Variables, RequestParameters, CacheConfig } from "relay-runtime";
|
||||
import { Environment, Network, RecordSource, Store } from "relay-runtime";
|
||||
|
||||
export const fetchRelay = async (
|
||||
const fetchRelay = async (
|
||||
params: RequestParameters,
|
||||
variables: Variables,
|
||||
_cacheConfig: CacheConfig
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { FC } from "react";
|
||||
import React from "react";
|
||||
import { Switch, Route } from "react-router-dom";
|
||||
|
||||
import { Home, Orders, Wallet } from "./pages";
|
||||
import { Dashbaord, Home, Orders, Wallet } from "./pages";
|
||||
|
||||
export const Routes: FC = () => {
|
||||
return (
|
||||
@@ -10,6 +10,9 @@ export const Routes: FC = () => {
|
||||
<Route exact path="/">
|
||||
<Home />
|
||||
</Route>
|
||||
<Route exact path="/dashboard">
|
||||
<Dashbaord />
|
||||
</Route>
|
||||
<Route exact path="/wallet">
|
||||
<Wallet />
|
||||
</Route>
|
||||
|
||||
@@ -14,6 +14,10 @@ const MenuItems: MenuItem[] = [
|
||||
label: "Início",
|
||||
path: "/",
|
||||
},
|
||||
{
|
||||
label: "Dashbaord",
|
||||
path: "/dashboard",
|
||||
},
|
||||
{
|
||||
label: "Carteira",
|
||||
path: "/wallet",
|
||||
|
||||
28
app/javascript/src/pages/Dashboard/Dashboard.tsx
Normal file
28
app/javascript/src/pages/Dashboard/Dashboard.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import type { FC } from "react";
|
||||
import React from "react";
|
||||
import useSWR from "swr";
|
||||
|
||||
import { useCurrentUser } from "../../contexts/UserProvider";
|
||||
import type { YieldwatchResponse } from "../../types/yieldwatch";
|
||||
|
||||
export const Dashbaord: FC = () => {
|
||||
const { user } = useCurrentUser();
|
||||
|
||||
const { data } = useSWR<YieldwatchResponse>(
|
||||
`https://www.yieldwatch.net/api/all/${user?.walletAddress}?platforms=pancake`
|
||||
);
|
||||
|
||||
if (data?.status === "0" || !data) return null;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<ul>
|
||||
<li>Ganho: {data.result.PancakeSwap.staking.totalUSDValues.yield}</li>
|
||||
<li>
|
||||
Depositado: {data.result.PancakeSwap.staking.totalUSDValues.deposit}
|
||||
</li>
|
||||
<li>Total: {data.result.PancakeSwap.staking.totalUSDValues.total}</li>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
1
app/javascript/src/pages/Dashboard/index.ts
Normal file
1
app/javascript/src/pages/Dashboard/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./Dashboard";
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from "./Dashboard";
|
||||
export * from "./Home";
|
||||
export * from "./Wallet";
|
||||
export * from "./Orders";
|
||||
export * from "./Wallet";
|
||||
|
||||
85
app/javascript/src/types/yieldwatch.d.ts
vendored
Normal file
85
app/javascript/src/types/yieldwatch.d.ts
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
type WatchBalance = {
|
||||
USDPrice: number;
|
||||
totalBalance: number;
|
||||
maxMonitorValue: number;
|
||||
walletBalance: number;
|
||||
watchFromLP: number;
|
||||
};
|
||||
|
||||
type Currencies = {
|
||||
EUR: number;
|
||||
RMB: number;
|
||||
JPY: number;
|
||||
GBP: number;
|
||||
BTCB: number;
|
||||
WBNB: number;
|
||||
BRL: number;
|
||||
AUD: number;
|
||||
HKD: number;
|
||||
SGD: number;
|
||||
RUB: number;
|
||||
KRW: number;
|
||||
CAD: number;
|
||||
THB: number;
|
||||
CHF: number;
|
||||
IDR: number;
|
||||
TRY: number;
|
||||
TWD: number;
|
||||
};
|
||||
|
||||
type TotalUSDValues = {
|
||||
deposit: number;
|
||||
yield: number;
|
||||
total: number;
|
||||
};
|
||||
|
||||
type Vaults = {
|
||||
totalUSDValues: TotalUSDValues;
|
||||
vaults: any[];
|
||||
};
|
||||
|
||||
type TotalUSDValues2 = {
|
||||
deposit: number;
|
||||
yield: number;
|
||||
total: number;
|
||||
};
|
||||
|
||||
type LPStaking = {
|
||||
totalUSDValues: TotalUSDValues2;
|
||||
vaults: any[];
|
||||
};
|
||||
|
||||
type TotalUSDValues3 = {
|
||||
deposit: number;
|
||||
yield: number;
|
||||
total: number;
|
||||
};
|
||||
|
||||
type Staking = {
|
||||
totalUSDValues: TotalUSDValues3;
|
||||
vaults: any[];
|
||||
};
|
||||
|
||||
type PancakeSwap = {
|
||||
vaults: Vaults;
|
||||
LPStaking: LPStaking;
|
||||
staking: Staking;
|
||||
};
|
||||
|
||||
type WalletBalance = {
|
||||
totalUSDValue: number;
|
||||
balances: any[];
|
||||
};
|
||||
|
||||
type Result = {
|
||||
watchBalance: WatchBalance;
|
||||
currencies: Currencies;
|
||||
PancakeSwap: PancakeSwap;
|
||||
};
|
||||
|
||||
export type YieldwatchResponse = {
|
||||
status: "0" | "1";
|
||||
message: string;
|
||||
result: Result;
|
||||
};
|
||||
Reference in New Issue
Block a user