From 96d7f27819833e3e0b965e40f40fd1d3ec818c5c Mon Sep 17 00:00:00 2001 From: James Grugett Date: Wed, 6 Apr 2022 22:34:05 -0500 Subject: [PATCH] No bet panel! --- common/util/format.ts | 15 +++++++++++++ web/components/amount-input.tsx | 15 ++++++++----- web/components/answers/answer-bet-panel.tsx | 2 +- web/components/bet-panel.tsx | 23 ++++++++++++++----- web/components/bet-row.tsx | 6 +++-- web/components/contract-overview.tsx | 24 +++++++++++--------- web/components/yes-no-selector.tsx | 25 ++++++++++----------- web/pages/[username]/[contractSlug].tsx | 8 ++----- 8 files changed, 75 insertions(+), 43 deletions(-) diff --git a/common/util/format.ts b/common/util/format.ts index 05a8f702..d1be7086 100644 --- a/common/util/format.ts +++ b/common/util/format.ts @@ -7,12 +7,27 @@ const formatter = new Intl.NumberFormat('en-US', { minimumFractionDigits: 0, }) +const formatterCents = new Intl.NumberFormat('en-US', { + style: 'currency', + currency: 'USD', + maximumFractionDigits: 2, + minimumFractionDigits: 2, +}) + export function formatMoney(amount: number) { const newAmount = Math.round(amount) === 0 ? 0 : amount // handle -0 case return ( ENV_CONFIG.moneyMoniker + ' ' + formatter.format(newAmount).replace('$', '') ) } +export function formatCents(probability: number) { + const newAmount = Math.round(probability * 100) === 0 ? 0 : probability // handle -0 case + return ( + ENV_CONFIG.moneyMoniker + + ' ' + + formatterCents.format(newAmount).replace('$', '') + ) +} export function formatWithCommas(amount: number) { return formatter.format(amount).replace('$', '') diff --git a/web/components/amount-input.tsx b/web/components/amount-input.tsx index f0a64a6b..ff4802d3 100644 --- a/web/components/amount-input.tsx +++ b/web/components/amount-input.tsx @@ -9,6 +9,7 @@ import { InfoTooltip } from './info-tooltip' import { Spacer } from './layout/spacer' import { calculateCpmmSale } from '../../common/calculate-cpmm' import { Binary, CPMM, FullContract } from '../../common/contract' +import { ENV_CONFIG } from '../../common/envs/constants' export function AmountInput(props: { amount: number | undefined @@ -50,10 +51,10 @@ export function AmountInput(props: { return (