2020-04-14 13:45:38 -07:00
|
|
|
import React from 'react';
|
2020-03-27 13:59:38 -07:00
|
|
|
import { FormattedNumber } from 'react-intl';
|
|
|
|
|
2021-11-16 05:12:55 -08:00
|
|
|
export const isNumber = number => typeof number === 'number' && !isNaN(number);
|
2021-07-13 12:26:34 -07:00
|
|
|
|
2020-03-27 13:59:38 -07:00
|
|
|
export const shortNumberFormat = number => {
|
2021-07-13 12:26:34 -07:00
|
|
|
if (!isNumber(number)) return '•';
|
|
|
|
|
2020-03-27 13:59:38 -07:00
|
|
|
if (number < 1000) {
|
|
|
|
return <FormattedNumber value={number} />;
|
|
|
|
} else {
|
|
|
|
return <span><FormattedNumber value={number / 1000} maximumFractionDigits={1} />K</span>;
|
|
|
|
}
|
|
|
|
};
|
2022-03-16 18:54:41 -07:00
|
|
|
|
|
|
|
export const isIntegerId = id => new RegExp(/^-?[0-9]+$/g).test(id);
|