File size: 468 Bytes
021e065
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
export function FinancialNumber({ amount, currency = "KES", positive = null }) {
  const formatted = new Intl.NumberFormat('en-KE', {
    minimumFractionDigits: 0,
    maximumFractionDigits: 0
  }).format(Math.abs(amount))
  
  const isPositive = positive !== null ? positive : amount >= 0
  
  return (
    <span className={`
      font-mono text-inherit
      ${isPositive ? 'text-emerald-600' : 'text-red-500'}
    `}>
      {currency} {formatted}
    </span>
  )
}