Skip to content

Commit

Permalink
Merge pull request #1488 from bancorprotocol/issue-#1439
Browse files Browse the repository at this point in the history
Replace source and target from searchParams with useState
  • Loading branch information
tiagofilipenunes committed Sep 20, 2024
2 parents c224f3e + cdf197b commit 43412eb
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 27 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 4 additions & 23 deletions src/components/trade/tradeWidget/useBuySell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@ import { TradeWidgetBuySellProps } from 'components/trade/tradeWidget/TradeWidge
import { useTradeAction } from 'components/trade/tradeWidget/useTradeAction';
import { prettifyNumber } from 'utils/helpers';
import { isTouchedZero, isZero } from 'components/strategies/common/utils';
import { useNavigate, useSearch } from '@tanstack/react-router';
import { TradeMarketSearch } from 'libs/routing/routes/trade';

export const useBuySell = ({
source,
target,
sourceBalanceQuery,
buy = false,
}: TradeWidgetBuySellProps) => {
const { source: sourceInput = '', target: targetInput = '' } = useSearch({
strict: false,
}) as TradeMarketSearch;
const [sourceInput, setSourceInput] = useState('');
const [targetInput, setTargetInput] = useState('');
const { user, provider } = useWagmi();
const { openModal } = useModal();
const { selectedFiatCurrency } = useFiatCurrency();
Expand All @@ -53,22 +50,6 @@ export const useBuySell = ({
target.address
);

const navigate = useNavigate({ from: '/trade/market' });
const setSourceInput = (value: string) => {
navigate({
search: (s) => ({ ...s, source: value }),
replace: true,
resetScroll: false,
});
};
const setTargetInput = (value: string) => {
navigate({
search: (s) => ({ ...s, target: value }),
replace: true,
resetScroll: false,
});
};

const { getFiatValue: getFiatValueSource } = useFiatCurrency(source);

const clearInputs = useCallback(() => {
Expand Down Expand Up @@ -251,8 +232,8 @@ export const useBuySell = ({
target,
tradeActions,
isTradeBySource,
sourceInput: sourceInput,
targetInput: targetInput,
sourceInput,
targetInput,
});

if (approval.approvalRequired) {
Expand Down
4 changes: 0 additions & 4 deletions src/libs/routing/routes/trade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ export type SetOverlapping = (next: OverlappingSearch) => any;
// TRADE MARKET
export interface TradeMarketSearch extends TradeSearch {
direction?: StrategyDirection;
source?: string;
target?: string;
}

// ROUTES
Expand Down Expand Up @@ -87,8 +85,6 @@ const marketPage = new Route({
priceStart: validNumber,
priceEnd: validNumber,
direction: validLiteral(['buy', 'sell']),
source: validNumber,
target: validNumber,
}),
});

Expand Down

0 comments on commit 43412eb

Please sign in to comment.