Skip to content

Commit 4f01273

Browse files
committed
Merge branch 'frontend-use-navigate'
2 parents 39f90f8 + a64e9db commit 4f01273

File tree

28 files changed

+89
-67
lines changed

28 files changed

+89
-67
lines changed

frontends/web/src/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
*/
1717

1818
import { useCallback, useEffect, Fragment } from 'react';
19+
import { useNavigate } from 'react-router-dom';
1920
import { useTranslation } from 'react-i18next';
20-
import { useNavigate } from 'react-router';
2121
import { useSync } from './hooks/api';
2222
import { useDefault } from './hooks/default';
2323
import { usePrevious } from './hooks/previous';

frontends/web/src/components/sidebar/sidebar.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
*/
1717

1818
import React, { useContext, useEffect, useState } from 'react';
19-
import { useLocation } from 'react-router';
20-
import { Link, NavLink } from 'react-router-dom';
19+
import { Link, NavLink, useLocation } from 'react-router-dom';
2120
import { useTranslation } from 'react-i18next';
2221
import { useKeystores } from '@/hooks/backend';
2322
import type { TDevices } from '@/api/devices';

frontends/web/src/routes/account/actionButtons.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
*/
1616

1717
import { MouseEvent } from 'react';
18+
import { Link, useNavigate } from 'react-router-dom';
1819
import { useTranslation } from 'react-i18next';
19-
import { Link } from 'react-router-dom';
20-
import { useNavigate } from 'react-router';
2120
import { WalletConnectLight } from '@/components/icon';
2221
import { useMediaQuery } from '@/hooks/mediaquery';
2322
import { connectKeystore, AccountCode, IAccount, CoinCode } from '@/api/account';

frontends/web/src/routes/account/add/add.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import React, { useCallback, useEffect, useRef, useState } from 'react';
18+
import { useNavigate } from 'react-router-dom';
1819
import { useTranslation } from 'react-i18next';
1920
import * as backendAPI from '@/api/backend';
2021
import * as keystoresAPI from '@/api/keystores';
@@ -26,7 +27,6 @@ import { Step, Steps } from './components/steps';
2627
import { CoinDropDown } from './components/coin-dropdown';
2728
import { Check } from '@/components/icon/icon';
2829
import { AddAccountGuide } from './add-account-guide';
29-
import { route } from '@/utils/route';
3030
import { addAccount, CoinCode, TAddAccount, IAccount } from '@/api/account';
3131
import styles from './add.module.css';
3232

@@ -37,6 +37,7 @@ type TAddAccountGuide = {
3737
type TStep = 'select-coin' | 'choose-name' | 'success';
3838

3939
export const AddAccount = ({ accounts }: TAddAccountGuide) => {
40+
const navigate = useNavigate();
4041
const [accountCode, setAccountCode] = useState<string>();
4142
const [accountName, setAccountName] = useState('');
4243
const [coinCode, setCoinCode] = useState<'choose' | CoinCode>('choose');
@@ -87,7 +88,7 @@ export const AddAccount = ({ accounts }: TAddAccountGuide) => {
8788
const back = () => {
8889
switch (step) {
8990
case 'select-coin':
90-
route('/settings/manage-accounts');
91+
navigate('/settings/manage-accounts');
9192
break;
9293
case 'choose-name':
9394
setStep('select-coin');
@@ -122,7 +123,7 @@ export const AddAccount = ({ accounts }: TAddAccountGuide) => {
122123
break;
123124
case 'success':
124125
if (accountCode) {
125-
route(`/account/${accountCode}`);
126+
navigate(`/account/${accountCode}`);
126127
}
127128
break;
128129
}

frontends/web/src/routes/account/info/info.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
*/
1717

1818
import { useState } from 'react';
19+
import { useNavigate } from 'react-router-dom';
1920
import { useTranslation } from 'react-i18next';
2021
import { useLoad } from '@/hooks/api';
2122
import { useEsc } from '@/hooks/keyboard';
2223
import { getInfo, IAccount, AccountCode } from '@/api/account';
23-
import { route } from '@/utils/route';
2424
import { isBitcoinBased } from '@/routes/account/utils';
2525
import { ButtonLink } from '@/components/forms';
2626
import { Header } from '@/components/layout';
@@ -37,12 +37,13 @@ export const Info = ({
3737
accounts,
3838
code,
3939
}: TProps) => {
40+
const navigate = useNavigate();
4041
const { t } = useTranslation();
4142
const info = useLoad(getInfo(code));
4243
const [viewXPub, setViewXPub] = useState<number>(0);
4344
const account = accounts.find(({ code: accountCode }) => accountCode === code);
4445

45-
useEsc(() => route(`/account/${code}`));
46+
useEsc(() => navigate(`/account/${code}`));
4647

4748
if (!account || !info) {
4849
return null;

frontends/web/src/routes/account/info/signingconfiguration.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
*/
1717

1818
import { useState, ReactNode } from 'react';
19+
import { useNavigate } from 'react-router-dom';
1920
import { useTranslation } from 'react-i18next';
20-
import { route } from '@/utils/route';
2121
import { AccountCode, IAccount, TBitcoinSimple, TEthereumSimple, TSigningConfiguration, verifyXPub } from '@/api/account';
2222
import { getScriptName, isBitcoinBased } from '@/routes/account/utils';
2323
import { alertUser } from '@/components/alert/Alert';
@@ -35,6 +35,7 @@ type TProps = {
3535
}
3636

3737
export const SigningConfiguration = ({ account, info, code, signingConfigIndex, children }: TProps) => {
38+
const navigate = useNavigate();
3839
const { t } = useTranslation();
3940
const [verifying, setVerifying] = useState(false);
4041

@@ -111,7 +112,7 @@ export const SigningConfiguration = ({ account, info, code, signingConfigIndex,
111112
{t('accountInfo.verify')}
112113
</Button>
113114
) : (
114-
<Button className={style.verifyButton} primary onClick={() => route(`/account/${code}/receive`)}>
115+
<Button className={style.verifyButton} primary onClick={() => navigate(`/account/${code}/receive`)}>
115116
{t('receive.verify')}
116117
</Button>
117118
) }

frontends/web/src/routes/account/receive/receive-bb01.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
*/
1717

1818
import React, { useEffect, useRef, useState } from 'react';
19+
import { useNavigate } from 'react-router-dom';
1920
import { useTranslation } from 'react-i18next';
2021
import { useLoad } from '@/hooks/api';
2122
import { useEsc } from '@/hooks/keyboard';
2223
import * as accountApi from '@/api/account';
23-
import { route } from '@/utils/route';
2424
import { getScriptName, isEthereumBased } from '@/routes/account/utils';
2525
import { alertUser } from '@/components/alert/Alert';
2626
import { CopyableInput } from '@/components/copy/Copy';
@@ -63,6 +63,7 @@ export const Receive = ({
6363
code,
6464
deviceID,
6565
}: TProps) => {
66+
const navigate = useNavigate();
6667
const { t } = useTranslation();
6768
const [verifying, setVerifying] = useState<boolean>(false);
6869
const [activeIndex, setActiveIndex] = useState<number>(0);
@@ -79,7 +80,7 @@ export const Receive = ({
7980
const receiveAddresses = useLoad(accountApi.getReceiveAddressList(code));
8081
const secureOutput = useLoad(accountApi.hasSecureOutput(code));
8182

82-
useEsc(() => !verifying && route(`/account/${code}`));
83+
useEsc(() => !verifying && navigate(`/account/${code}`));
8384

8485
const availableScriptTypes = useRef<accountApi.ScriptType[]>();
8586

frontends/web/src/routes/account/receive/receive.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
*/
1717

1818
import React, { useEffect, useRef, useState } from 'react';
19+
import { useNavigate } from 'react-router-dom';
1920
import { useTranslation } from 'react-i18next';
2021
import { useLoad } from '@/hooks/api';
2122
import { useEsc } from '@/hooks/keyboard';
2223
import * as accountApi from '@/api/account';
23-
import { route } from '@/utils/route';
2424
import { getScriptName, isEthereumBased } from '@/routes/account/utils';
2525
import { CopyableInput } from '@/components/copy/Copy';
2626
import { Dialog, DialogButtons } from '@/components/dialog/dialog';
@@ -114,6 +114,7 @@ export const Receive = ({
114114
accounts,
115115
code,
116116
}: TProps) => {
117+
const navigate = useNavigate();
117118
const { t } = useTranslation();
118119
const [verifying, setVerifying] = useState<false | 'secure' | 'insecure'>(false);
119120
const [activeIndex, setActiveIndex] = useState<number>(0);
@@ -133,7 +134,7 @@ export const Receive = ({
133134

134135
const hasManyScriptTypes = availableScriptTypes.current && availableScriptTypes.current.length > 1;
135136

136-
useEsc(() => !addressTypeDialog && !verifying && route(`/account/${code}`));
137+
useEsc(() => !addressTypeDialog && !verifying && navigate(`/account/${code}`));
137138

138139
useEffect(() => {
139140
if (receiveAddresses) {

frontends/web/src/routes/account/summary/balancerow.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { useNavigate } from 'react-router-dom';
1718
import { useTranslation } from 'react-i18next';
1819
import { AccountCode, CoinCode, IBalance } from '@/api/account';
1920
import { syncAddressesCount } from '@/api/accountsync';
2021
import { useSubscribe } from '@/hooks/api';
21-
import { route } from '@/utils/route';
2222
import { Logo } from '@/components/icon/logo';
2323
import { Amount } from '@/components/amount/amount';
2424
import { AsciiSpinner } from '@/components/spinner/ascii';
@@ -35,14 +35,15 @@ type TProps = {
3535
export const BalanceRow = (
3636
{ code, name, coinCode, balance }: TProps
3737
) => {
38+
const navigate = useNavigate();
3839
const { t } = useTranslation();
3940
const syncStatus = useSubscribe(syncAddressesCount(code));
4041

4142
const nameCol = (
4243
<td
4344
className={style.clickable}
4445
data-label={t('accountSummary.name')}
45-
onClick={() => route(`/account/${code}`)}>
46+
onClick={() => navigate(`/account/${code}`)}>
4647
<div className={style.coinName}>
4748
<Logo className={style.coincode} coinCode={coinCode} active={true} alt={coinCode} />
4849
{name}

frontends/web/src/routes/account/walletconnect/components/connect-form/connect-form.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
*/
1616

1717
import { SetStateAction, useState } from 'react';
18+
import { useNavigate } from 'react-router-dom';
1819
import { useTranslation } from 'react-i18next';
1920
import * as accountAPI from '@/api/account';
2021
import { Button, Input } from '@/components/forms';
21-
import { route } from '@/utils/route';
2222
import { useMediaQuery } from '@/hooks/mediaquery';
2323
import { ScanQRButton } from '@/routes/account/send/components/inputs/receiver-address-input';
2424
import { ScanQRDialog } from '@/routes/account/send/components/dialogs/scan-qr-dialog';
@@ -52,6 +52,7 @@ export const WCConnectForm = ({
5252
onSubmit,
5353
connectLoading
5454
}: TWCConnectFormProps) => {
55+
const navigate = useNavigate();
5556
const { t } = useTranslation();
5657
const isMobile = useMediaQuery('(max-width: 768px)');
5758
const [activeScanQR, setActiveScanQR] = useState(isMobile); // default to true on mobile
@@ -95,7 +96,7 @@ export const WCConnectForm = ({
9596
<Button
9697
disabled={connectLoading}
9798
secondary
98-
onClick={() => route(`/account/${code}/wallet-connect/dashboard`)}>
99+
onClick={() => navigate(`/account/${code}/wallet-connect/dashboard`)}>
99100
{t('dialog.cancel')}
100101
</Button>
101102
<Button

0 commit comments

Comments
 (0)