Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pete-watters committed Jul 8, 2024
1 parent 8523e75 commit 769b458
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 37 deletions.
38 changes: 2 additions & 36 deletions src/app/features/container/containers/page/page.header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,10 @@ import { Settings } from '../../../settings/settings';
import { HeaderActionButton } from '../headers/components/header-action-button';
import { usePageContext } from './page.context';

// if you go to send and hit a broadcast error,
// - when you close the error
// - then go back on the send form
// it will show the error again
// so for 'confirm' routes, we need to go back to the send form
// RouteUrls.SendStxConfirmation -> navigate(RouteUrls.SendCryptoAssetForm.replace(':symbol', 'stx'))
// I had this implemented in the switch for 'stx' and 'btc' but seems to miss other tokens e.g. mojo etc.

// it's the same issue with the Fund routes, probably for everything that has a dialog and a Back button

// PETE - test this onGoBack function to see if its needed
// TODO: Refactor? This is very hard to manage with dynamic routes. Temporarily
// added a fix to catch the swap route: '/swap/:base/:quote?'
// function getOnGoBackLocation(pathname: RouteUrls) {
// if (pathname.includes('/swap')) return navigate(RouteUrls.Home);
// switch (pathname) {

// > PETE next up is:
// - to fix this on go back

// fixed fund, now handle swap and send
// onBackLocation: RouteUrls.Fund.replace(':currency', currency) as RouteUrls,

// - figure out state reset for unlock
// TODO
// - solve send page memory leak + fix this on go back
// - work on getting rid of the popup route functions

// case RouteUrls.SendCryptoAssetForm.replace(':symbol', 'stx'):
// case RouteUrls.SendCryptoAssetForm.replace(':symbol', 'btc'):
// return navigate(RouteUrls.Home);
// case RouteUrls.SendStxConfirmation:
// return navigate(RouteUrls.SendCryptoAssetForm.replace(':symbol', 'stx'));
// case RouteUrls.SendBtcConfirmation:
// return navigate(RouteUrls.SendCryptoAssetForm.replace(':symbol', 'btc'));
// default:
// return navigate(-1);
// }
// }

function LogoBox({ isSessionLocked }: { isSessionLocked: boolean | undefined }) {
const navigate = useNavigate();
return (
Expand Down
5 changes: 4 additions & 1 deletion src/app/pages/swap/swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { useFormikContext } from 'formik';
import { Button } from '@leather.io/ui';
import { isUndefined } from '@leather.io/utils';

import { RouteUrls } from '@shared/route-urls';

import { LoadingSpinner } from '@app/components/loading-spinner';
import { Footer } from '@app/features/container/containers/footers/footer';
import { useUpdatePageHeaderContext } from '@app/features/container/containers/page/page.context';
Expand All @@ -19,7 +21,8 @@ import { SwapFormValues } from './hooks/use-swap-form';
import { useSwapContext } from './swap.context';

export function Swap() {
useUpdatePageHeaderContext({ title: 'Swap' });
// Swap uses routed dialogs to choose assets so needs onBackLocation to go Home
useUpdatePageHeaderContext({ title: 'Swap', onBackLocation: RouteUrls.Home });
const { isFetchingExchangeRate, swappableAssetsBase, swappableAssetsQuote } = useSwapContext();
const { dirty, isValid, setFieldValue, values, validateForm } =
useFormikContext<SwapFormValues>();
Expand Down

0 comments on commit 769b458

Please sign in to comment.