improved formatting
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
export const formatCurrency = (amount:number) => {
|
||||
// format number wirh 2 decimal places and a thousand separator
|
||||
// amount is in cents
|
||||
const formattedAmount = (amount/100).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
|
||||
return(formattedAmount);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ export const Page = async () => {
|
||||
<div className="card card-compact card-bordered max-w-[36em] bg-base-100 shadow-s my-1">
|
||||
<span className="card-body self-center">
|
||||
<p>
|
||||
Total monthly expenditure: <strong>{ formatCurrency(monthlyExpense/100) }</strong>
|
||||
Total monthly expenditure: <strong>{ formatCurrency(monthlyExpense) }</strong>
|
||||
</p>
|
||||
</span>
|
||||
</div> : null
|
||||
|
||||
Reference in New Issue
Block a user