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 (
- Price - + + Price + + {lastPrice} + + {" "} + {basePair} +
- 24h Change + + 24h Change + - {change} + {isNegativeOrZero ? change : "+" + change} + %
- 24h High - - {high} + + 24h Volume + + + {volume} + + {" "} + {basePair} +
- 24h Low - - {low} + + 24h High + + + {high} + + {" "} + {basePair} +
- 24h Volume - - {volume} + + 24h Low + + + {low} + + {" "} + {basePair} +