Skip to content

Commit

Permalink
wip: fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
shanimal08 committed Nov 11, 2024
1 parent 0ba5284 commit 4bb1bbf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/containers/main/SideBar/Miner/Miner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useFormatBalance } from '@app/utils/formatBalance.ts';
import { Typography } from '@app/components/elements/Typography.tsx';

import { useAppConfigStore } from '@app/store/useAppConfigStore.ts';
import { useHardwareStats } from '@app/hooks/useHardwareStats.ts';

import useMiningStatesSync from '@app/hooks/mining/useMiningStatesSync.ts';
import { useTheme } from 'styled-components';
import { Trans, useTranslation } from 'react-i18next';
Expand All @@ -23,7 +23,6 @@ export default function Miner() {
const theme = useTheme();
const { t } = useTranslation('mining-view', { useSuspense: false });
useMiningStatesSync();
const { cpu: cpuHardwareStats, gpu: gpuHardwareStats } = useHardwareStats();
const miningInitiated = useMiningStore((s) => s.miningInitiated);
const isCpuMiningEnabled = useAppConfigStore((s) => s.cpu_mining_enabled);
const isGpuMiningEnabled = useAppConfigStore((s) => s.gpu_mining_enabled);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/formatBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { formatNumber } from '@app/utils/formatNumber.ts';
import { useCallback } from 'react';

export default function formatBalance(value: number, locale?: string, maxDigitsArg?: number) {
const balance = value / 1_000_000;
const balance = Math.floor(value / 1_000_000);
const maxDigits = balance > 1_000_000 ? 2 : balance < 10 ? 3 : 1;
return formatNumber(balance, maxDigitsArg || maxDigits, locale);
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/formatNumber.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export function formatNumber(value: number, maxDigits = 3, locale?: string): string {
//TODO: add props for customisation
const valFloor = Math.floor(value);
return Intl.NumberFormat(locale, {
notation: 'compact',
maximumFractionDigits: maxDigits,
style: 'decimal',
}).format(value);
}).format(valFloor);
}
export function formatPercent(value = 0) {
const p = Math.floor(value || 0).toLocaleString();
Expand Down

0 comments on commit 4bb1bbf

Please sign in to comment.