currency formatter function moved to utils dir

This commit is contained in:
Gustavo Mauricio 2022-09-14 17:51:14 +01:00
parent cd08b567fb
commit ace7be48b5
4 changed files with 11 additions and 7 deletions

View File

@ -132,7 +132,7 @@ const ConnectModal = ({ isOpen, onClose }: Props) => {
) : (
<div className="flex flex-col gap-3 mt-2">
<button
className="flex items-center p-4 bg-black/90 rounded-xl hover:bg-black/70"
className="flex items-center p-4 bg-black/90 rounded-xl hover:bg-black"
onClick={handleConnectMetamask}
>
<Image
@ -162,7 +162,7 @@ const ConnectModal = ({ isOpen, onClose }: Props) => {
</div>
</button>
<button
className="flex items-center p-4 bg-black/90 rounded-xl hover:bg-black/70"
className="flex items-center p-4 bg-black/90 rounded-xl hover:bg-black"
onClick={handleConnectKeplr}
>
<Image

View File

@ -7,6 +7,7 @@ import { ChevronDownIcon } from "@heroicons/react/24/solid";
import SearchInput from "components/SearchInput";
import ProgressBar from "components/ProgressBar";
import Wallet from "./Wallet";
import { formatCurrency } from "utils/formatters";
const mockedAccounts = [
{
@ -102,7 +103,7 @@ const Navigation = () => {
</Popover>
</div>
<div className="flex gap-4 items-center">
<p>$: 2500</p>
<p>$: ${formatCurrency(2500)}</p>
<div>Lvg</div>
<div>Risk</div>
<ProgressBar value={0.43} />

View File

@ -1,5 +1,7 @@
import React from "react";
import Container from "components/Container";
import { formatCurrency } from "utils/formatters";
const mockedAccounts = [
{
@ -71,6 +73,7 @@ const Portfolio = () => {
account.profit > 0 ? "text-green-400" : "text-red-500"
}`}
>
{account.profit > 0 && "+"}
{formatCurrency(account.profit)}
</p>
<p className="text-sm text-white/40">P&L</p>
@ -92,7 +95,3 @@ const Portfolio = () => {
};
export default Portfolio;
function formatCurrency(value: string | number) {
return Number(value).toLocaleString();
}

View File

@ -11,3 +11,7 @@ export const formatWalletAddress = (
address.length
)}`;
};
export const formatCurrency = (value: string | number) => {
return Number(value).toLocaleString();
};