Skip to content

Commit

Permalink
fix: fix routing issues with send flow
Browse files Browse the repository at this point in the history
  • Loading branch information
pete-watters committed Mar 29, 2024
1 parent a6bda2d commit cc1aa60
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -32,6 +32,7 @@ interface ConfirmationRouteBtcArgs {

export function useSendFormNavigate() {
const navigate = useNavigate();
const location = useLocation();

return useMemo(
() => ({
Expand All @@ -43,7 +44,8 @@ export function useSendFormNavigate() {
utxos: UtxoResponseItem[],
values: BitcoinSendFormValues
) {
return navigate('choose-fee', {
return navigate(RouteUrls.SendBtcChooseFee, {
replace: true,
state: {
isSendingMax,
utxos,
Expand All @@ -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()),
Expand All @@ -82,8 +84,7 @@ export function useSendFormNavigate() {
name,
tx,
}: ConfirmationRouteStacksSip10Args) {
return navigate('confirm', {
replace: true,
return navigate(`${location.pathname}/confirm`, {
state: {
decimals,
token: name,
Expand All @@ -102,6 +103,6 @@ export function useSendFormNavigate() {
});
},
}),
[navigate]
[navigate, location]
);
}

0 comments on commit cc1aa60

Please sign in to comment.