From cc1aa60f1e9d76529da92b170cafdaf2060ccca9 Mon Sep 17 00:00:00 2001 From: Pete Watters <2938440+pete-watters@users.noreply.github.com> Date: Fri, 29 Mar 2024 12:27:37 +0000 Subject: [PATCH] fix: fix routing issues with send flow --- .../hooks/use-send-form-navigate.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app/pages/send/send-crypto-asset-form/hooks/use-send-form-navigate.ts b/src/app/pages/send/send-crypto-asset-form/hooks/use-send-form-navigate.ts index 4243f5411d4..1a761a11bf4 100644 --- a/src/app/pages/send/send-crypto-asset-form/hooks/use-send-form-navigate.ts +++ b/src/app/pages/send/send-crypto-asset-form/hooks/use-send-form-navigate.ts @@ -1,5 +1,5 @@ import { useMemo } from 'react'; -import { useNavigate } from 'react-router-dom'; +import { useLocation, useNavigate } from 'react-router-dom'; import { bytesToHex } from '@stacks/common'; import { StacksTransaction } from '@stacks/transactions'; @@ -32,6 +32,7 @@ interface ConfirmationRouteBtcArgs { export function useSendFormNavigate() { const navigate = useNavigate(); + const location = useLocation(); return useMemo( () => ({ @@ -43,7 +44,8 @@ export function useSendFormNavigate() { utxos: UtxoResponseItem[], values: BitcoinSendFormValues ) { - return navigate('choose-fee', { + return navigate(RouteUrls.SendBtcChooseFee, { + replace: true, state: { isSendingMax, utxos, @@ -69,7 +71,7 @@ export function useSendFormNavigate() { }); }, toConfirmAndSignStxTransaction(tx: StacksTransaction, showFeeChangeWarning: boolean) { - return navigate('confirm', { + return navigate(RouteUrls.SendStxConfirmation, { replace: true, state: { tx: bytesToHex(tx.serialize()), @@ -82,8 +84,7 @@ export function useSendFormNavigate() { name, tx, }: ConfirmationRouteStacksSip10Args) { - return navigate('confirm', { - replace: true, + return navigate(`${location.pathname}/confirm`, { state: { decimals, token: name, @@ -102,6 +103,6 @@ export function useSendFormNavigate() { }); }, }), - [navigate] + [navigate, location] ); }