Show decimals on 98%+
This commit is contained in:
		
							parent
							
								
									434c7b6b97
								
							
						
					
					
						commit
						d6a751d9a2
					
				| 
						 | 
				
			
			@ -19,8 +19,8 @@ export function formatWithCommas(amount: number) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
export function formatPercent(zeroToOne: number) {
 | 
			
		||||
  // Show 1 decimal place if <2% or >99%
 | 
			
		||||
  const decimalPlaces = zeroToOne < 0.02 || zeroToOne > 0.99 ? 1 : 0
 | 
			
		||||
  // Show 1 decimal place if <2% or >98%, giving more resolution on the tails
 | 
			
		||||
  const decimalPlaces = zeroToOne < 0.02 || zeroToOne > 0.98 ? 1 : 0
 | 
			
		||||
  return (zeroToOne * 100).toFixed(decimalPlaces) + '%'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -95,7 +95,7 @@ export function AnswerBetPanel(props: {
 | 
			
		|||
    : 0
 | 
			
		||||
 | 
			
		||||
  const currentReturn = betAmount ? (currentPayout - betAmount) / betAmount : 0
 | 
			
		||||
  const currentReturnPercent = (currentReturn * 100).toFixed() + '%'
 | 
			
		||||
  const currentReturnPercent = formatPercent(currentReturn)
 | 
			
		||||
 | 
			
		||||
  return (
 | 
			
		||||
    <Col className={clsx('px-2 pb-2 pt-4 sm:pt-0', className)}>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -112,7 +112,7 @@ export function BetPanel(props: {
 | 
			
		|||
    : 0
 | 
			
		||||
 | 
			
		||||
  const currentReturn = betAmount ? (currentPayout - betAmount) / betAmount : 0
 | 
			
		||||
  const currentReturnPercent = (currentReturn * 100).toFixed() + '%'
 | 
			
		||||
  const currentReturnPercent = formatPercent(currentReturn)
 | 
			
		||||
 | 
			
		||||
  const panelTitle = title ?? 'Place a trade'
 | 
			
		||||
  if (title) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user