Skip to content

Commit

Permalink
Merge pull request #101 from benscobie/format-percentage
Browse files Browse the repository at this point in the history
Format interest rate
  • Loading branch information
benscobie authored Sep 22, 2024
2 parents fb5d53f + 607ea13 commit d314238
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/ui/molecules/MonthLoanTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
ChevronLeft,
ChevronRight,
} from 'react-bootstrap-icons'
import { percentFormatter } from '../../../utils/percentFormatter'

interface MonthLoanTableProps {
results: Results
Expand Down Expand Up @@ -134,7 +135,7 @@ export const MonthLoanTable: NextPage<MonthLoanTableProps> = ({
)}
</td>
<td className="border-b border-l px-2 py-1.5 sm:px-3 md:px-4">
{projection.interestRate * 100}%
{percentFormatter.format(projection.interestRate)}
</td>
<td className="border-b border-l px-2 py-1.5 sm:px-3 md:px-4">
{currencyFormatterNoFraction.format(projection.threshold)}
Expand Down
5 changes: 5 additions & 0 deletions utils/percentFormatter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const percentFormatter = new Intl.NumberFormat('en-GB', {
style: 'percent',
minimumFractionDigits: 0,
maximumFractionDigits: 2,
})

0 comments on commit d314238

Please sign in to comment.