diff --git a/src/app/components/PriceInfo.tsx b/src/app/components/PriceInfo.tsx index b1a7b108..2ac02cf2 100644 --- a/src/app/components/PriceInfo.tsx +++ b/src/app/components/PriceInfo.tsx @@ -1,65 +1,114 @@ import React from "react"; import { useAppSelector } from "../hooks"; +import { displayAmount } from "../utils"; export function PriceInfo() { const priceInfo = useAppSelector((state) => state.priceInfo); - const lastPrice = priceInfo.lastPrice; - const change = priceInfo.change24h; - const high = priceInfo.high24h; - const low = priceInfo.low24h; - const volume = priceInfo.value24h; + const noDigits = 4; + const decimalSeparator = "."; + const thousandSeparator = ","; + const fixedDecimals = 3; + const lastPrice = displayAmount( + priceInfo.lastPrice, + noDigits, + decimalSeparator, + thousandSeparator, + fixedDecimals + ); + const change = displayAmount( + priceInfo.change24h, + noDigits, + decimalSeparator, + thousandSeparator, + fixedDecimals + ); + const high = displayAmount( + priceInfo.high24h, + noDigits, + decimalSeparator, + thousandSeparator, + fixedDecimals + ); + const low = displayAmount( + priceInfo.low24h, + noDigits, + decimalSeparator, + thousandSeparator, + fixedDecimals + ); + const volume = displayAmount( + priceInfo.value24h, + noDigits, + decimalSeparator, + thousandSeparator, + fixedDecimals + ); const isNegativeOrZero = priceInfo.isNegativeOrZero; + const basePair = "XRD"; return (