From 9e4f8f9441ca630325b524be89909b572c220974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Geonizeli?= Date: Fri, 20 Aug 2021 16:18:55 -0300 Subject: [PATCH] improve staking dashboard --- .../src/components/SideNav/SideNav.tsx | 2 +- .../src/pages/Dashboard/Dashboard.tsx | 114 ++++++++++-------- app/javascript/src/types/yieldwatch.d.ts | 2 +- 3 files changed, 67 insertions(+), 51 deletions(-) diff --git a/app/javascript/src/components/SideNav/SideNav.tsx b/app/javascript/src/components/SideNav/SideNav.tsx index 98eb554..7b52c1c 100644 --- a/app/javascript/src/components/SideNav/SideNav.tsx +++ b/app/javascript/src/components/SideNav/SideNav.tsx @@ -15,7 +15,7 @@ const MenuItems: MenuItem[] = [ path: "/", }, { - label: "Dashbaord", + label: "Minhas Posições", path: "/dashboard", }, { diff --git a/app/javascript/src/pages/Dashboard/Dashboard.tsx b/app/javascript/src/pages/Dashboard/Dashboard.tsx index 91ef210..19b25dd 100644 --- a/app/javascript/src/pages/Dashboard/Dashboard.tsx +++ b/app/javascript/src/pages/Dashboard/Dashboard.tsx @@ -1,9 +1,17 @@ import type { FC } from "react"; import React from "react"; import useSWR from "swr"; +import cx from "classnames"; import { useCurrentUser } from "../../contexts/UserProvider"; -import type { YieldwatchResponse } from "../../types/yieldwatch"; +import type { Vault, YieldwatchResponse } from "../../types/yieldwatch"; + +const exampleVault: Partial = { + chainId: 1, + name: "Cake-Cake Staking", + depositedTokens: 0, + totalRewards: 0, +}; export const Dashbaord: FC = () => { const { user } = useCurrentUser(); @@ -12,58 +20,66 @@ export const Dashbaord: FC = () => { `https://www.yieldwatch.net/api/all/${user?.walletAddress}?platforms=pancake` ); - if (data?.status === "0" || !data) return null; + const isLoading = !data; + + const vaults = data?.result?.PancakeSwap?.staking?.vaults ?? [exampleVault]; return ( -
+
- - - - - - - - - - {data.result.PancakeSwap.staking.vaults.map((vault) => { - return ( - - - - - - ); - })} - -
( +
+

+ {vault.name} +

+
+

- Pool -

- Depositado - - Ganho -
-

- {vault.name} -

-
-

- {vault.depositedTokens.toFixed(4)} -

-
-

- {vault.totalRewards.toFixed(4)} -

-
+ {!isLoading && + ( + (vault.depositedTokens ?? 0) + (vault.totalRewards ?? 0) + ).toFixed(4)} +

+
+
+
+

Depositado

+
+ {!isLoading && vault.depositedTokens?.toFixed(4)} +
+
+
+

Ganho

+
+ {!isLoading && vault.totalRewards?.toFixed(4)} +
+
+
+
+ ))}
); diff --git a/app/javascript/src/types/yieldwatch.d.ts b/app/javascript/src/types/yieldwatch.d.ts index 2d64201..9335d57 100644 --- a/app/javascript/src/types/yieldwatch.d.ts +++ b/app/javascript/src/types/yieldwatch.d.ts @@ -60,7 +60,7 @@ type PoolInfo = { apr: number; }; -type Vault = { +export type Vault = { type: string; name: string; platform: string;