2020-08-17 21:07:16 +01:00
|
|
|
import React from 'react'
|
2020-02-08 06:12:01 +00:00
|
|
|
import { FormattedNumber } from 'react-intl'
|
2019-07-02 08:10:25 +01:00
|
|
|
|
2020-04-29 03:24:35 +01:00
|
|
|
export const shortNumberFormat = (number) => {
|
2019-07-02 08:10:25 +01:00
|
|
|
if (number < 1000) {
|
2020-04-29 03:24:35 +01:00
|
|
|
try {
|
|
|
|
return (<FormattedNumber value={number} />).props.value
|
|
|
|
} catch (error) {
|
|
|
|
return <FormattedNumber value={number} />
|
|
|
|
}
|
2019-07-02 08:10:25 +01:00
|
|
|
}
|
2020-01-29 21:53:33 +00:00
|
|
|
|
2020-02-08 06:12:01 +00:00
|
|
|
return (
|
2020-08-17 21:07:16 +01:00
|
|
|
<React.Fragment>
|
2020-05-13 01:36:54 +01:00
|
|
|
<FormattedNumber value={number / 1000} maximumFractionDigits={1} />k
|
2020-08-17 21:07:16 +01:00
|
|
|
</React.Fragment>
|
2020-02-08 06:12:01 +00:00
|
|
|
)
|
|
|
|
}
|
2020-07-28 21:07:55 +01:00
|
|
|
|
|
|
|
export const getRandomInt = (min, max) => {
|
|
|
|
min = Math.ceil(min)
|
|
|
|
max = Math.floor(max)
|
|
|
|
return Math.floor(Math.random() * (max - min + 1)) + min
|
|
|
|
}
|