mirror of
https://github.com/RoboSats/robosats.git
synced 2025-09-13 00:56:22 +00:00
* Add SVG icons for map pins * Add federation basis and new coordinator form (#793) * Add new coordinator entry issue form * Add Federation basis * Fix eslint errors from F2F and fix languages * Redo eslint @typescript-eslint/strict-boolean-expressions * Robot Page working * Contexts Working * Garage Working * CurrentOrder working * Federation model working --------- Co-authored-by: Reckless_Satoshi <reckless.satoshi@protonmail.com> Co-authored-by: Reckless_Satoshi <90936742+Reckless-Satoshi@users.noreply.github.com>
31 lines
759 B
TypeScript
31 lines
759 B
TypeScript
export const pn = (value?: number | null): string => {
|
|
if (value === null || value === undefined) {
|
|
return String();
|
|
}
|
|
|
|
const parts = value.toString().split('.');
|
|
|
|
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
|
|
return parts.join('.');
|
|
};
|
|
|
|
export const amountToString: (
|
|
amount: string,
|
|
has_range: boolean,
|
|
min_amount: number,
|
|
max_amount: number,
|
|
precision?: number,
|
|
) => string = (amount, has_range, min_amount, max_amount, precision = 4) => {
|
|
if (has_range) {
|
|
return (
|
|
pn(parseFloat(Number(min_amount).toPrecision(precision))) +
|
|
'-' +
|
|
pn(parseFloat(Number(max_amount).toPrecision(precision)))
|
|
);
|
|
}
|
|
return pn(parseFloat(Number(amount).toPrecision(precision))) ?? '';
|
|
};
|
|
|
|
export default pn;
|