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-08-03 12:29:36 -07:00
|
|
|
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>;
|
|
|
|
}
|
|
|
|
};
|