move manaToUSD to format.ts (#172)
This commit is contained in:
parent
b97301c6fa
commit
a297f6492d
|
@ -16,6 +16,13 @@ export function formatWithCommas(amount: number) {
|
|||
return formatter.format(Math.floor(amount)).replace('$', '')
|
||||
}
|
||||
|
||||
export function manaToUSD(mana: number) {
|
||||
return (mana / 100).toLocaleString('en-US', {
|
||||
style: 'currency',
|
||||
currency: 'USD',
|
||||
})
|
||||
}
|
||||
|
||||
export function formatPercent(zeroToOne: number) {
|
||||
// Show 1 decimal place if <2% or >98%, giving more resolution on the tails
|
||||
const decimalPlaces = zeroToOne < 0.02 || zeroToOne > 0.98 ? 1 : 0
|
||||
|
|
|
@ -4,7 +4,7 @@ import Link from 'next/link'
|
|||
import Image from 'next/image'
|
||||
import { Charity } from 'common/charity'
|
||||
import { useCharityTxns } from 'web/hooks/use-charity-txns'
|
||||
import { manaToUSD } from '../../pages/charity/[charitySlug]'
|
||||
import { manaToUSD } from '../../../common/util/format'
|
||||
import { Row } from '../layout/row'
|
||||
|
||||
export function CharityCard(props: { charity: Charity }) {
|
||||
|
|
|
@ -2,7 +2,7 @@ import { Txn } from 'common/txn'
|
|||
import { Avatar } from '../avatar'
|
||||
import { useUserById } from 'web/hooks/use-users'
|
||||
import { UserLink } from '../user-page'
|
||||
import { manaToUSD } from '../../pages/charity/[charitySlug]'
|
||||
import { manaToUSD } from '../../../common/util/format'
|
||||
import { RelativeTimestamp } from '../relative-timestamp'
|
||||
|
||||
export function Donation(props: { txn: Txn }) {
|
||||
|
|
|
@ -19,9 +19,7 @@ import { useWindowSize } from 'web/hooks/use-window-size'
|
|||
import Confetti from 'react-confetti'
|
||||
import { Donation } from 'web/components/charity/feed-items'
|
||||
import Image from 'next/image'
|
||||
|
||||
export const manaToUSD = (mana: number) =>
|
||||
(mana / 100).toLocaleString('en-US', { style: 'currency', currency: 'USD' })
|
||||
import { manaToUSD } from '../../../common/util/format'
|
||||
|
||||
export default function CharityPageWrapper() {
|
||||
const router = useRouter()
|
||||
|
|
Loading…
Reference in New Issue
Block a user