Skip to content

Commit

Permalink
added comma between stats number in landing
Browse files Browse the repository at this point in the history
  • Loading branch information
alimaktabi committed Jan 28, 2024
1 parent 099b9c9 commit ea5870e
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions components/containers/landing/stats.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import { countGasClaimedAPI, countUsersAPI } from "@/utils/api"
import Widget from "./widget"
import { FC } from "react"
import { Chain } from "@/types"
import { countGasClaimedAPI, countUsersAPI } from "@/utils/api";
import Widget from "./widget";
import { FC } from "react";
import { Chain } from "@/types";
import { numberWithCommas } from "@/utils";

export const getTotalNetworks = (chains: Chain[]) => {
return chains.reduce((total, chain) => total + (!chain.isTestnet ? 1 : 0), 0)
}
return chains.reduce((total, chain) => total + (!chain.isTestnet ? 1 : 0), 0);
};

export const getTotalTestNetworks = (chains: Chain[]) => {
return chains.reduce((total, chain) => total + (chain.isTestnet ? 1 : 0), 0)
}
return chains.reduce((total, chain) => total + (chain.isTestnet ? 1 : 0), 0);
};

const LandingStats: FC<{ chains: Chain[] }> = async ({ chains }) => {
const usersCount = await countUsersAPI()
const gasClaimedCount = await countGasClaimedAPI()
const usersCount = await countUsersAPI();
const gasClaimedCount = await countGasClaimedAPI();

const stats = [
{ name: "Main Networks", number: getTotalNetworks(chains) },
{ name: "Test Networks", number: getTotalTestNetworks(chains) },
]
];

return (
<section id="home-stats" className={"flex gap-4 justify-between"}>
Expand Down Expand Up @@ -47,7 +48,7 @@ const LandingStats: FC<{ chains: Chain[] }> = async ({ chains }) => {
<div key={stat.name} className={"flex flex-col gap-2 items-center"}>
<p className={"text-xl text-space-green font-semibold"}>
{/* {numberWithCommas(typeof stat.number == 'string' ? parseFloat(stat.number) : stat.number)} */}
{stat.number}
{numberWithCommas(stat.number)}
</p>
<p className={"text-gradient-primary text-xs font-medium"}>
{stat.name}
Expand All @@ -66,7 +67,7 @@ const LandingStats: FC<{ chains: Chain[] }> = async ({ chains }) => {
</div>
</Widget>
</section>
)
}
);
};

export default LandingStats
export default LandingStats;

0 comments on commit ea5870e

Please sign in to comment.