mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
31 lines
705 B
TypeScript
31 lines
705 B
TypeScript
import { kebabCase } from 'lodash';
|
|
import { ITableRow } from '@/interfaces';
|
|
|
|
export const formatNumber = (balance, { noCents, divideOn1000 }): string => {
|
|
let formattedBalance: number = parseFloat(balance);
|
|
|
|
if (noCents) {
|
|
formattedBalance = parseInt(formattedBalance, 10);
|
|
}
|
|
if (divideOn1000) {
|
|
formattedBalance /= 1000;
|
|
}
|
|
return formattedBalance;
|
|
};
|
|
|
|
export const tableClassNames = (rows: ITableRow[]) => {
|
|
return rows.map((row) => {
|
|
const classNames =
|
|
row?.rowTypes?.map((rowType) => `row-type--${kebabCase(rowType)}`) || [];
|
|
|
|
if (row.id) {
|
|
classNames.push(`row-id--${kebabCase(row.id)}`);
|
|
}
|
|
|
|
return {
|
|
...row,
|
|
classNames,
|
|
};
|
|
});
|
|
};
|