You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
911 B
29 lines
911 B
import React, { useContext } from 'react';
|
|
|
|
import { AppContext } from '../components/ContextProvider';
|
|
|
|
|
|
export const ToCoins = props => {
|
|
const { state } = useContext(AppContext);
|
|
const { appSettings } = state;
|
|
const { coins, symbol } = props;
|
|
|
|
return (<>{coins / Math.pow(10, appSettings.coinDecimals)} {symbol || String.fromCharCode(appSettings.coinSymbol)}</>);
|
|
}
|
|
|
|
export const ToDate = props => {
|
|
const { timeStamp } = props;
|
|
return (<>{new Date(timeStamp * 1000).toLocaleString()}</>);
|
|
}
|
|
|
|
export const ToHashes = props => {
|
|
const { hashes, suffix = 'hashes' } = props;
|
|
|
|
let res = `${(hashes || 0)} ${suffix}`;
|
|
if (hashes > 1e3) res = `${parseFloat((hashes / 1e3).toFixed(2))} kilo${suffix}`;
|
|
if (hashes > 1e6) res = `${parseFloat((hashes / 1e6).toFixed(2))} mega${suffix}`;
|
|
if (hashes > 1e9) res = `${parseFloat((hashes / 1e9).toFixed(2))} giga${suffix}`;
|
|
|
|
return (<>{res}</>);
|
|
}
|