Skip to content

Commit

Permalink
feat(coinmarket): add default amounts of fiat currencies
Browse files Browse the repository at this point in the history
  • Loading branch information
adderpositive committed Jul 1, 2024
1 parent d3d3755 commit 41856f2
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
41 changes: 40 additions & 1 deletion packages/suite/src/constants/wallet/coinmarket/fiatCurrencies.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
import { FiatCurrencyCode } from '@suite-common/suite-config';

const defaultFiatCurrencies = new Map<FiatCurrencyCode, string>([['czk', '3000']]);
const defaultFiatCurrencies = new Map<FiatCurrencyCode, string>([
['usd', '150'],
['eur', '100'],
['gbp', '100'],
['aed', '400'],
['ars', '100000'],
['aud', '200'],
['bdt', '12000'],
['brl', '600'],
['cad', '150'],
['chf', '100'],
['clp', '100000'],
['cny', '800'],
['czk', '2500'],
['dkk', '800'],
['hkd', '900'],
['huf', '40000'],
['idr', '1500000'],
['ils', '400'],
['inr', '9000'],
['jpy', '17000'],
['krw', '150000'],
['kwd', '30'],
['lkr', '30000'],
['mxn', '2000'],
['myr', '500'],
['nok', '1200'],
['nzd', '200'],
['php', '6500'],
['pln', '400'],
['rub', '9000'],
['sar', '400'],
['sek', '1200'],
['sgd', '150'],
['thb', '4000'],
['try', '3500'],
['twd', '3500'],
['vnd', '2500000'],
['zar', '2000'],
]);

export default defaultFiatCurrencies;
5 changes: 5 additions & 0 deletions packages/suite/src/types/wallet/coinmarketCommonTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
SavingsTradeItem,
} from 'invity-api';
import type { FlagProps } from '@trezor/components';
import { FiatCurrencyCode } from '@suite-common/suite-config';

type CommonTrade = {
date: string;
Expand All @@ -32,6 +33,10 @@ export type Option = { value: string; label: string };
export type CountryOption = { value: FlagProps['country']; label: string };
export type DefaultCountryOption = { value: string; label: string };
export type TranslationOption = { value: string; label?: ReactElement };
export type FiatCurrencyOption = {
value: FiatCurrencyCode;
label: string;
};

export type PaymentFrequencyOption = Option & { label: JSX.Element };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { fiatCurrencies } from '@suite-common/suite-config';
import { useCoinmarketFormContext } from 'src/hooks/wallet/coinmarket/form/useCoinmarketCommonForm';
import { CoinmarketTradeBuyType } from 'src/types/coinmarket/coinmarket';
import { useDidUpdate } from '@trezor/react-utils';
import defaultFiatCurrencies from 'src/constants/wallet/coinmarket/fiatCurrencies';
import { FiatCurrencyOption } from 'src/types/wallet/coinmarketCommonTypes';

const CoinmarketFormInputFiat = () => {
const { translationString } = useTranslation();
Expand Down Expand Up @@ -88,9 +90,10 @@ const CoinmarketFormInputFiat = () => {
render={({ field: { onChange, value } }) => (
<Select
value={value}
onChange={(selected: any) => {
onChange={(selected: FiatCurrencyOption) => {
onChange(selected);
setAmountLimits(undefined);
setValue(fiatInput, defaultFiatCurrencies.get(selected.value));
}}
options={Object.keys(fiatCurrencies)
.filter(c => buyInfo?.supportedFiatCurrencies.has(c))
Expand Down

0 comments on commit 41856f2

Please sign in to comment.