diff --git a/apps/marketplace/src/modules/sale/utils.ts b/apps/marketplace/src/modules/sale/utils.ts index 4716c8ea..cc4e24be 100644 --- a/apps/marketplace/src/modules/sale/utils.ts +++ b/apps/marketplace/src/modules/sale/utils.ts @@ -13,6 +13,8 @@ export const transformApiSale = (apiSale: ApiSale): Sale => { return { ...sale, + // TODO: look into back-end returning value with correct decimal places + costAmount: sale.costAmount / 1000000, song: { ...song, isExplicit: parentalAdvisory === "Explicit", diff --git a/packages/components/src/lib/SongCard.tsx b/packages/components/src/lib/SongCard.tsx index 36740c5c..cdcfd26b 100644 --- a/packages/components/src/lib/SongCard.tsx +++ b/packages/components/src/lib/SongCard.tsx @@ -11,6 +11,7 @@ import { PlayArrow, Stop } from "@mui/icons-material"; import { bgImage } from "@newm-web/assets"; import { formatNewmAmount, + formatUsdAmount, getImageSrc, resizeCloudinaryImage, } from "@newm-web/utils"; @@ -232,6 +233,7 @@ const SongCard = ({ { priceVariant === "text" && ( -  (≈ { currency(priceInUsd).format() }) +  (≈ { formatUsdAmount(priceInUsd) }) ) } diff --git a/packages/utils/src/lib/crypto.ts b/packages/utils/src/lib/crypto.ts index e93b63b0..39742a38 100644 --- a/packages/utils/src/lib/crypto.ts +++ b/packages/utils/src/lib/crypto.ts @@ -9,7 +9,18 @@ export const formatNewmAmount = (amount?: number, includeSymbol = true) => { return currency(amount, { pattern: "# !", - precision: 1, + precision: 2, symbol: includeSymbol ? "Ɲ" : "", }).format(); }; + +/** + * Formats a numerical USD amount to three decimal places + * rather than the standard two, based on the exchange rate + * for NEWM to USD. + */ +export const formatUsdAmount = (amount?: number, precision = 3) => { + if (!amount) return ""; + + return currency(amount, { precision }).format(); +};