diff --git a/frontends/web/src/components/accountselector/accountselector.tsx b/frontends/web/src/components/accountselector/accountselector.tsx index 5df02c568e..c11264186d 100644 --- a/frontends/web/src/components/accountselector/accountselector.tsx +++ b/frontends/web/src/components/accountselector/accountselector.tsx @@ -32,11 +32,12 @@ export type TOption = { } type TAccountSelector = { - title: string; - options: TOption[]; - selected?: string; - onChange: (value: string) => void; - onProceed: () => void; + title: string; + disabled?: boolean; + options: TOption[]; + selected?: string; + onChange: (value: string) => void; + onProceed: () => void; } const SelectSingleValue: FunctionComponent> = (props) => { @@ -80,7 +81,7 @@ const DropdownIndicator: FunctionComponent> = (p -export const AccountSelector = ({ title, options, selected, onChange, onProceed }: TAccountSelector) => { +export const AccountSelector = ({ title, disabled, options, selected, onChange, onProceed }: TAccountSelector) => { const { t } = useTranslation(); const [selectedAccount, setSelectedAccount] = useState(); @@ -118,11 +119,11 @@ export const AccountSelector = ({ title, options, selected, onChange, onProceed ); -}; \ No newline at end of file +}; diff --git a/frontends/web/src/routes/buy/info.tsx b/frontends/web/src/routes/buy/info.tsx index d740151502..6085b3d4d7 100644 --- a/frontends/web/src/routes/buy/info.tsx +++ b/frontends/web/src/routes/buy/info.tsx @@ -17,7 +17,7 @@ import { useState, useEffect, useCallback } from 'react'; import { useTranslation } from 'react-i18next'; import { route } from '../../utils/route'; -import { IAccount } from '../../api/account'; +import * as accountApi from '../../api/account'; import { getExchangeSupportedAccounts } from './utils'; import { getBalance } from '../../api/account'; import Guide from './guide'; @@ -29,13 +29,14 @@ import { View, ViewContent } from '../../components/view/view'; import { HideAmountsButton } from '../../components/hideamountsbutton/hideamountsbutton'; type TProps = { - accounts: IAccount[]; + accounts: accountApi.IAccount[]; code: string; } export const BuyInfo = ({ code, accounts }: TProps) => { const [selected, setSelected] = useState(code); const [options, setOptions] = useState(); + const [disabled, setDisabled] = useState(false); const { t } = useTranslation(); @@ -81,7 +82,17 @@ export const BuyInfo = ({ code, accounts }: TProps) => { }); }; - const handleProceed = () => { + const handleProceed = async () => { + setDisabled(true); + try { + const connectResult = await accountApi.connectKeystore(selected); + if (!connectResult.success) { + return; + } + } finally { + setDisabled(false); + } + route(`/buy/exchange/${selected}`); }; if (options === undefined) { @@ -105,6 +116,7 @@ export const BuyInfo = ({ code, accounts }: TProps) => { ) : (