-
Notifications
You must be signed in to change notification settings - Fork 2
feature(ui-ux): added dashboard stats #292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fullstackninja864
wants to merge
14
commits into
main
Choose a base branch
from
harsh/dashboard-stats
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3024795
feature:(ui-ux): added dashboard stats
fullstackninja864 465a746
added fullBorder in GradientCardContainer
fullstackninja864 4c38b8a
minor fixes and ui pudate
fullstackninja864 498954f
Update src/components/GroupStatisticCard.tsx
fullstackninja864 d711dab
Update src/components/GroupStatisticCard.tsx
fullstackninja864 7ffb33f
lint issue fixed
fullstackninja864 954cf9a
Update src/components/GroupStatisticCard.tsx
fullstackninja864 ed44596
used global constant for unit constant
fullstackninja864 42a4069
fixed dates issue
fullstackninja864 1f084a9
reverse the txn data for proper chart formation
fullstackninja864 a5ec491
removed txn count and gas price from graph footer
fullstackninja864 42e3e8c
Merge branch 'main' of github.com:WavesHQ/metascan into harsh/dashboa…
fullstackninja864 43d92e1
Merge branch 'main' into harsh/dashboard-stats
fullstackninja864 919fdcd
Merge branch 'main' into harsh/dashboard-stats
fullstackninja864 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,138 @@ | ||
| import React from "react"; | ||
| import { useState, useEffect } from "react"; | ||
| import StatisticCard from "@components/commons/StatisticCard"; | ||
| import clsx from "clsx"; | ||
| import { MdCheckCircle } from "react-icons/md"; | ||
| import LatestDataApi from "@api/LatestDataApi"; | ||
| import { useNetwork } from "@contexts/NetworkContext"; | ||
| import BigNumber from "bignumber.js"; | ||
| import { DashboardStatsProps, SmartContractStatsProps } from "@api/types"; | ||
| import NumericFormat from "./commons/NumericFormat"; | ||
|
|
||
| export default function GroupStatisticCard() { | ||
| const { connection } = useNetwork(); | ||
| const [isLoading, setIsLoading] = useState(false); | ||
| const [dashboardStats, setDashboardStats] = useState<DashboardStatsProps>(); | ||
| const [smartContractStats, setSmartContractStats] = | ||
| useState<SmartContractStatsProps>(); | ||
| const unit = "gwei"; | ||
| const fetchStats = async () => { | ||
| setIsLoading(true); | ||
| const dashStats = await LatestDataApi.getDashboardStats(connection); | ||
| setDashboardStats(dashStats); | ||
| const scStats = await LatestDataApi.getSmartContractStats(connection); | ||
| setSmartContractStats(scStats); | ||
| setIsLoading(false); | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| fetchStats(); | ||
| }, []); | ||
|
|
||
| function GroupStatisticCard() { | ||
| const groupStatsCardContent = [ | ||
| { | ||
| title: "24h total value locked", | ||
| body: "3232400000", | ||
| footer: "+2.34%", | ||
| testId: "24h-total-value-locked", | ||
| }, | ||
| { | ||
| title: "24h transactions", | ||
| body: "32324000000", | ||
| footer: "-0.02%", | ||
| testId: "24h-total-transactions", | ||
| }, | ||
| ]; | ||
| return ( | ||
| <div className="flex flex-col space-y-2 lg:space-y-0 md:space-y-0 lg:space-x-2 md:space-x-2 lg:flex-row md:flex-row"> | ||
| {groupStatsCardContent.map((card) => ( | ||
| <div> | ||
| <div className="flex flex-col space-y-5 md:space-y-0 md:flex-row md:space-x-7 md:justify-end md:px-10 mb-11 md:mb-8 lg:mb-[72px]"> | ||
| <div className="flex flex-row justify-between md:justify-start md:space-x-2 items-center"> | ||
| <span className="text-white-700 text-sm -tracking-[0.14px]"> | ||
| Gas Tracker: | ||
| </span> | ||
| <span className="text-white-50 text-base -tracking-[0.32px] font-semibold"> | ||
| {dashboardStats?.gas_prices.average} | ||
| </span> | ||
| </div> | ||
| <div className="flex flex-row justify-between md:justify-start md:space-x-2 items-center"> | ||
| <span className="text-white-700 text-sm -tracking-[0.14px]"> | ||
| Daily transactions: | ||
| </span> | ||
| <span className="text-white-50 text-base -tracking-[0.32px] font-semibold"> | ||
| {dashboardStats?.transactions_today} | ||
| </span> | ||
| </div> | ||
| </div> | ||
| <div | ||
| className={clsx( | ||
| "grid grid-cols-1 gap-4", | ||
| "grid md:grid-cols-2 gap-6", | ||
| "grid lg:grid-cols-4 gap-6" | ||
| )} | ||
| > | ||
| <StatisticCard | ||
| key={card.title} | ||
| title={card.title} | ||
| body={card.body} | ||
| footer={card.footer} | ||
| testId={card.testId} | ||
| /> | ||
| ))} | ||
| title="Blocks" | ||
| value={new BigNumber(dashboardStats?.total_blocks ?? 0)} | ||
| testId="blocks" | ||
| isLoading={isLoading} | ||
| > | ||
| <span> | ||
| {`Avg. speed: ${new BigNumber( | ||
| dashboardStats?.average_block_time ?? 0 | ||
| ) | ||
| .dividedBy(1000) | ||
| .toFixed(1)} sec`} | ||
| </span> | ||
| </StatisticCard> | ||
|
|
||
| <StatisticCard | ||
| title="Transactions" | ||
| value={new BigNumber(dashboardStats?.total_transactions ?? 0)} | ||
| testId="transactions" | ||
| isLoading={isLoading} | ||
| > | ||
| <NumericFormat | ||
| value={new BigNumber(dashboardStats?.transactions_today ?? 0)} | ||
| thousandSeparator | ||
| prefix={`Today: `} | ||
| suffix={` transactions`} | ||
| decimalScale={0} | ||
| /> | ||
| </StatisticCard> | ||
|
|
||
| <StatisticCard | ||
| title="Contracts" | ||
| value={ | ||
| new BigNumber(smartContractStats?.verified_smart_contracts ?? 0) | ||
| } | ||
| testId="contracts" | ||
| isLoading={isLoading} | ||
| > | ||
| <span className="flex flex-row items-center"> | ||
| <NumericFormat | ||
| value={new BigNumber( | ||
| smartContractStats?.verified_smart_contracts ?? 0 | ||
| ) | ||
| .multipliedBy(smartContractStats?.smart_contracts ?? 0) | ||
| .dividedBy(100) | ||
| .toFixed(2)} | ||
| thousandSeparator | ||
| suffix="% verified" | ||
| decimalScale={2} | ||
| /> | ||
| <MdCheckCircle className="h-5 w-5 ml-1 text-green-800" /> | ||
| </span> | ||
| </StatisticCard> | ||
|
|
||
| <StatisticCard | ||
| title="Gas price" | ||
| value={new BigNumber(dashboardStats?.gas_prices.average ?? 0)} | ||
| testId="gas-price" | ||
| suffix={` ${unit}`} | ||
| isLoading={isLoading} | ||
| > | ||
| <NumericFormat | ||
| value={new BigNumber(dashboardStats?.gas_prices.fast ?? 0)} | ||
| thousandSeparator | ||
| prefix={`High: `} | ||
| suffix={` ${unit}`} | ||
| decimalScale={0} | ||
| /> | ||
| <NumericFormat | ||
| value={new BigNumber(dashboardStats?.gas_prices.slow ?? 0)} | ||
| thousandSeparator | ||
| prefix={`Low: `} | ||
| suffix={` ${unit}`} | ||
| decimalScale={0} | ||
| className="ml-2" | ||
| /> | ||
| </StatisticCard> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default GroupStatisticCard; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.