diff --git a/src/renderer/src/routes/pages/Send/SendAmount.tsx b/src/renderer/src/routes/pages/Send/SendAmount.tsx
index 33ee2a690..64eef53c2 100644
--- a/src/renderer/src/routes/pages/Send/SendAmount.tsx
+++ b/src/renderer/src/routes/pages/Send/SendAmount.tsx
@@ -6,11 +6,11 @@ import { TokenBalance } from '@renderer/@types/query'
import { IAccountState } from '@renderer/@types/store'
import { Button } from '@renderer/components/Button'
import { BalanceHelper } from '@renderer/helpers/BalanceHelper'
-import { FilterHelper } from '@renderer/helpers/FilterHelper'
import { NumberHelper } from '@renderer/helpers/NumberHelper'
import { StyleHelper } from '@renderer/helpers/StyleHelper'
import { useBalancesAndExchange } from '@renderer/hooks/useBalancesAndExchange'
import { useModalNavigate } from '@renderer/hooks/useModalRouter'
+import { useCurrencySelector } from '@renderer/hooks/useSettingsSelector'
type TAmountParams = {
selectedAccount?: IAccountState
@@ -29,10 +29,11 @@ export const SendAmount = ({
}: TAmountParams) => {
const { t } = useTranslation('pages', { keyPrefix: 'send' })
const { modalNavigateWrapper } = useModalNavigate()
+ const { currency } = useCurrencySelector()
const balanceExchange = useBalancesAndExchange(selectedAccount ? [selectedAccount] : [])
const estimatedFee = useMemo(() => {
- if (!selectedToken || !selectedAmount) return FilterHelper.currency(0)
+ if (!selectedToken || !selectedAmount) return NumberHelper.currency(0, currency.label)
const pricePerToken = BalanceHelper.getExchangeRatio(
selectedToken.token.hash,
@@ -40,8 +41,8 @@ export const SendAmount = ({
balanceExchange.exchange.data
)
- return FilterHelper.currency(NumberHelper.number(selectedAmount) * pricePerToken)
- }, [selectedToken, selectedAmount, balanceExchange])
+ return NumberHelper.currency(NumberHelper.number(selectedAmount) * pricePerToken, currency.label)
+ }, [selectedToken, selectedAmount, currency.label, balanceExchange.exchange.data])
return (
@@ -81,7 +82,7 @@ export const SendAmount = ({
- {t('fiatValue')}
+ {t('fiatValue', { currencyType: currency.label })}
{estimatedFee}
diff --git a/src/renderer/src/routes/pages/Send/TotalFee.tsx b/src/renderer/src/routes/pages/Send/TotalFee.tsx
index df124b681..9fefca6f4 100644
--- a/src/renderer/src/routes/pages/Send/TotalFee.tsx
+++ b/src/renderer/src/routes/pages/Send/TotalFee.tsx
@@ -6,6 +6,7 @@ import { Loader } from '@renderer/components/Loader'
import { BalanceHelper } from '@renderer/helpers/BalanceHelper'
import { NumberHelper } from '@renderer/helpers/NumberHelper'
import { useExchange } from '@renderer/hooks/useExchange'
+import { useCurrencySelector } from '@renderer/hooks/useSettingsSelector'
import { TSendServiceResponse } from '.'
@@ -18,6 +19,7 @@ type TTotalFeeParams = {
export const TotalFee = ({ getSendFields, onFeeChange, fee }: TTotalFeeParams) => {
const { t } = useTranslation('pages', { keyPrefix: 'send' })
const exchange = useExchange()
+ const { currency } = useCurrencySelector()
const [fiatFee, setFiatFee] = useState()
const [loading, setLoading] = useState(false)
@@ -71,7 +73,7 @@ export const TotalFee = ({ getSendFields, onFeeChange, fee }: TTotalFeeParams) =
) : (
{fee}
- {NumberHelper.currency(fiatFee ?? 0)}
+ {NumberHelper.currency(fiatFee ?? 0, currency.label)}
)}
diff --git a/src/renderer/src/routes/pages/Settings/SettingsCurrency/index.tsx b/src/renderer/src/routes/pages/Settings/SettingsCurrency/index.tsx
new file mode 100644
index 000000000..e5ee1dc27
--- /dev/null
+++ b/src/renderer/src/routes/pages/Settings/SettingsCurrency/index.tsx
@@ -0,0 +1,42 @@
+import { useState } from 'react'
+import { useTranslation } from 'react-i18next'
+import { TCurrency } from '@renderer/@types/store'
+import { RadioGroup } from '@renderer/components/RadioGroup'
+import { availableCurrencies } from '@renderer/constants/currency'
+import { useAppDispatch } from '@renderer/hooks/useRedux'
+import { useCurrencySelector } from '@renderer/hooks/useSettingsSelector'
+import { SettingsLayout } from '@renderer/layouts/Settings'
+import { settingsReducerActions } from '@renderer/store/reducers/SettingsReducer'
+
+export const SettingsCurrency = () => {
+ const { t } = useTranslation('pages', { keyPrefix: 'settings.settingsCurrency' })
+ const { currency } = useCurrencySelector()
+ const dispatch = useAppDispatch()
+
+ const [selectedCurrency, setSelectedCurrency] = useState(currency)
+
+ const onSelectRadioItem = (selectedValue: string) => {
+ const selectedCurrency = availableCurrencies.find(currency => currency.symbol === selectedValue)
+
+ if (!selectedCurrency) return
+
+ setSelectedCurrency(selectedCurrency)
+ dispatch(settingsReducerActions.setCurrency(selectedCurrency))
+ }
+
+ return (
+
+
+ {availableCurrencies.map(currency => (
+
+
+
{currency.symbol}
+
+
+
+
+ ))}
+
+
+ )
+}
diff --git a/src/renderer/src/routes/pages/Wallets/AccountList.tsx b/src/renderer/src/routes/pages/Wallets/AccountList.tsx
index 1ac22dfc5..828a0c22c 100644
--- a/src/renderer/src/routes/pages/Wallets/AccountList.tsx
+++ b/src/renderer/src/routes/pages/Wallets/AccountList.tsx
@@ -5,9 +5,10 @@ import { AccountIcon } from '@renderer/components/AccountIcon'
import { Separator } from '@renderer/components/Separator'
import { Tooltip } from '@renderer/components/Tooltip'
import { BalanceHelper } from '@renderer/helpers/BalanceHelper'
-import { FilterHelper } from '@renderer/helpers/FilterHelper'
+import { NumberHelper } from '@renderer/helpers/NumberHelper'
import { UtilsHelper } from '@renderer/helpers/UtilsHelper'
import { useAccountsByWalletIdSelector } from '@renderer/hooks/useAccountSelector'
+import { useCurrencySelector } from '@renderer/hooks/useSettingsSelector'
type TProps = {
onSelect: (account: IAccountState) => void
@@ -24,6 +25,8 @@ type TAccountItemProps = {
}
const AccountItem = ({ account, balanceExchange, onClick, active }: TAccountItemProps) => {
+ const { currency } = useCurrencySelector()
+
const totalTokensBalances = useMemo(
() =>
BalanceHelper.calculateTotalBalances(balanceExchange.balance.data, balanceExchange.exchange.data, [
@@ -32,7 +35,10 @@ const AccountItem = ({ account, balanceExchange, onClick, active }: TAccountItem
[balanceExchange, account]
)
- const formattedTotalTokensBalances = useMemo(() => FilterHelper.currency(totalTokensBalances), [totalTokensBalances])
+ const formattedTotalTokensBalances = useMemo(
+ () => NumberHelper.currency(totalTokensBalances || 0, currency.label),
+ [currency.label, totalTokensBalances]
+ )
return (
diff --git a/src/renderer/src/routes/pages/Wallets/AccountOverview/index.tsx b/src/renderer/src/routes/pages/Wallets/AccountOverview/index.tsx
index d0d38df5b..d1d3894dd 100644
--- a/src/renderer/src/routes/pages/Wallets/AccountOverview/index.tsx
+++ b/src/renderer/src/routes/pages/Wallets/AccountOverview/index.tsx
@@ -4,8 +4,9 @@ import { useOutletContext } from 'react-router-dom'
import { IAccountState } from '@renderer/@types/store'
import { BalanceChart } from '@renderer/components/BalanceChart'
import { BalanceHelper } from '@renderer/helpers/BalanceHelper'
-import { FilterHelper } from '@renderer/helpers/FilterHelper'
+import { NumberHelper } from '@renderer/helpers/NumberHelper'
import { useBalancesAndExchange } from '@renderer/hooks/useBalancesAndExchange'
+import { useCurrencySelector } from '@renderer/hooks/useSettingsSelector'
import { AccountDetailsLayout } from '@renderer/layouts/AccountDetailsLayout'
import { CommonAccountActions } from '../CommonAccountActions'
@@ -19,14 +20,17 @@ export const AccountOverview = () => {
const { account } = useOutletContext()
+ const { currency } = useCurrencySelector()
+
const balanceExchange = useBalancesAndExchange(account ? [account] : [])
const formattedTotalTokensBalances = useMemo(
() =>
- FilterHelper.currency(
- BalanceHelper.calculateTotalBalances(balanceExchange.balance.data, balanceExchange.exchange.data)
+ NumberHelper.currency(
+ BalanceHelper.calculateTotalBalances(balanceExchange.balance.data, balanceExchange.exchange.data) || 0,
+ currency.label
),
- [balanceExchange.balance.data, balanceExchange.exchange.data]
+ [balanceExchange.balance.data, balanceExchange.exchange.data, currency.label]
)
return (
diff --git a/src/renderer/src/routes/pages/Wallets/AccountTokensList/index.tsx b/src/renderer/src/routes/pages/Wallets/AccountTokensList/index.tsx
index 1d281ea74..18093c116 100644
--- a/src/renderer/src/routes/pages/Wallets/AccountTokensList/index.tsx
+++ b/src/renderer/src/routes/pages/Wallets/AccountTokensList/index.tsx
@@ -4,8 +4,9 @@ import { useOutletContext } from 'react-router-dom'
import { IAccountState } from '@renderer/@types/store'
import { TokensTable } from '@renderer/components/TokensTable'
import { BalanceHelper } from '@renderer/helpers/BalanceHelper'
-import { FilterHelper } from '@renderer/helpers/FilterHelper'
+import { NumberHelper } from '@renderer/helpers/NumberHelper'
import { useBalancesAndExchange } from '@renderer/hooks/useBalancesAndExchange'
+import { useCurrencySelector } from '@renderer/hooks/useSettingsSelector'
import { AccountDetailsLayout } from '@renderer/layouts/AccountDetailsLayout'
import { CommonAccountActions } from '../CommonAccountActions'
@@ -18,15 +19,17 @@ export const AccountTokensList = () => {
const { t } = useTranslation('pages', { keyPrefix: 'wallets.accountTokensList' })
const { account } = useOutletContext()
+ const { currency } = useCurrencySelector()
const balanceExchange = useBalancesAndExchange(account ? [account] : [])
const formattedTotalTokensBalances = useMemo(
() =>
- FilterHelper.currency(
- BalanceHelper.calculateTotalBalances(balanceExchange.balance.data, balanceExchange.exchange.data)
+ NumberHelper.currency(
+ BalanceHelper.calculateTotalBalances(balanceExchange.balance.data, balanceExchange.exchange.data) || 0,
+ currency.label
),
- [balanceExchange.balance.data, balanceExchange.exchange.data]
+ [balanceExchange.balance.data, balanceExchange.exchange.data, currency.label]
)
return (
diff --git a/src/renderer/src/routes/pages/Wallets/WalletSelectItem.tsx b/src/renderer/src/routes/pages/Wallets/WalletSelectItem.tsx
index 48cdbfaaa..7dc747fa4 100644
--- a/src/renderer/src/routes/pages/Wallets/WalletSelectItem.tsx
+++ b/src/renderer/src/routes/pages/Wallets/WalletSelectItem.tsx
@@ -5,9 +5,10 @@ import { Select } from '@renderer/components/Select'
import { Tooltip } from '@renderer/components/Tooltip'
import { WalletIcon } from '@renderer/components/WalletIcon'
import { BalanceHelper } from '@renderer/helpers/BalanceHelper'
-import { FilterHelper } from '@renderer/helpers/FilterHelper'
+import { NumberHelper } from '@renderer/helpers/NumberHelper'
import { StyleHelper } from '@renderer/helpers/StyleHelper'
import { useAccountsByWalletIdSelector } from '@renderer/hooks/useAccountSelector'
+import { useCurrencySelector } from '@renderer/hooks/useSettingsSelector'
type TProps = {
balanceExchange: UseMultipleBalanceAndExchangeResult
@@ -16,6 +17,7 @@ type TProps = {
export const WalletSelectItem = ({ balanceExchange, wallet }: TProps) => {
const { accountsByWalletId } = useAccountsByWalletIdSelector(wallet.id)
+ const { currency } = useCurrencySelector()
const totalTokensBalances = useMemo(
() =>
@@ -27,7 +29,10 @@ export const WalletSelectItem = ({ balanceExchange, wallet }: TProps) => {
[balanceExchange, accountsByWalletId]
)
- const formattedTotalTokensBalances = useMemo(() => FilterHelper.currency(totalTokensBalances), [totalTokensBalances])
+ const formattedTotalTokensBalances = useMemo(
+ () => NumberHelper.currency(totalTokensBalances || 0, currency.label),
+ [currency.label, totalTokensBalances]
+ )
return (
,
+ element: ,
},
{
path: 'release-notes',
diff --git a/src/renderer/src/store/reducers/SettingsReducer.ts b/src/renderer/src/store/reducers/SettingsReducer.ts
index 844d2668c..535738018 100644
--- a/src/renderer/src/store/reducers/SettingsReducer.ts
+++ b/src/renderer/src/store/reducers/SettingsReducer.ts
@@ -1,6 +1,7 @@
import { CaseReducer, createSlice, PayloadAction } from '@reduxjs/toolkit'
import { TNetworkType } from '@renderer/@types/blockchain'
-import { ISettingsState, TSecurityType } from '@renderer/@types/store'
+import { ISettingsState, TCurrency, TSecurityType } from '@renderer/@types/store'
+import { availableCurrencies } from '@renderer/constants/currency'
export const settingsReducerName = 'settingsReducer'
@@ -9,6 +10,7 @@ const initialState: ISettingsState = {
securityType: 'none',
isFirstTime: true,
networkType: 'mainnet',
+ currency: availableCurrencies[0],
}
const setEncryptedPassword: CaseReducer> = (state, action) => {
@@ -27,6 +29,10 @@ const setNetworkType: CaseReducer> =
state.networkType = action.payload
}
+const setCurrency: CaseReducer> = (state, action) => {
+ state.currency = action.payload
+}
+
const SettingsReducer = createSlice({
name: settingsReducerName,
initialState,
@@ -35,6 +41,7 @@ const SettingsReducer = createSlice({
setSecurityType,
setEncryptedPassword,
setNetworkType,
+ setCurrency,
},
})