Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
denniskigen committed Dec 1, 2023
1 parent 01e4418 commit ffb4911
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions packages/esm-billing-app/src/helpers/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@ export function calculateTotalAmount(lineItems: Array<LineItem>) {
: 0;
}

export const convertToCurreny = (amountToConvert: number) =>
new Intl.NumberFormat('en-KE', { currency: 'KSH', style: 'currency' }).format(amountToConvert);
export const convertToCurrency = (amountToConvert: number) => {
if (amountToConvert === 0) {
return '--';
}
return new Intl.NumberFormat('en-KE', { currency: 'KSH', style: 'currency' }).format(amountToConvert);
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { calculateTotalAmount, convertToCurreny } from '../helpers';
import { calculateTotalAmount, convertToCurrency } from '../helpers';
import { MappedBill } from '../types';

/**
Expand Down Expand Up @@ -32,8 +32,8 @@ export const useBillMetrics = (bills: Array<MappedBill>) => {
const cumulativeBills = calculateTotals();
const pendingBills = cumulativeBills - paidBills;
return {
cumulativeBills: convertToCurreny(cumulativeBills),
pendingBills: convertToCurreny(pendingBills),
paidBills: convertToCurreny(paidBills),
cumulativeBills: convertToCurrency(cumulativeBills),
pendingBills: convertToCurrency(pendingBills),
paidBills: convertToCurrency(paidBills),
};
};

0 comments on commit ffb4911

Please sign in to comment.