Skip to content

Commit

Permalink
fix(hooks): link hooks page to swap trade state (#4698)
Browse files Browse the repository at this point in the history
  • Loading branch information
shoom3301 authored Jul 10, 2024
1 parent 306059e commit bab250c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/cowswap-frontend/src/common/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export const TRADE_WIDGET_PREFIX = isInjectedWidget() ? '/widget' : ''
export const Routes = {
HOME: '/',
SWAP: `/:chainId?${TRADE_WIDGET_PREFIX}/swap/:inputCurrencyId?/:outputCurrencyId?`,
HOOKS: `/:chainId?${TRADE_WIDGET_PREFIX}/swap/hooks/:inputCurrencyId?/:outputCurrencyId?`,
LIMIT_ORDER: `/:chainId?${TRADE_WIDGET_PREFIX}/limit/:inputCurrencyId?/:outputCurrencyId?`,
ADVANCED_ORDERS: `/:chainId?${TRADE_WIDGET_PREFIX}/advanced/:inputCurrencyId?/:outputCurrencyId?`,
HOOKS: `/:chainId?${TRADE_WIDGET_PREFIX}/hooks/:inputCurrencyId?/:outputCurrencyId?`,
LONG_LIMIT_ORDER: `/:chainId?${TRADE_WIDGET_PREFIX}/limit-orders/:inputCurrencyId?/:outputCurrencyId?`,
LONG_ADVANCED_ORDERS: `/:chainId?${TRADE_WIDGET_PREFIX}/advanced-orders/:inputCurrencyId?/:outputCurrencyId?`,
SEND: '/send',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import { TradeType, TradeTypeInfo } from '../types'

export function useTradeTypeInfoFromUrl(): TradeTypeInfo | null {
const swapMatch = !!useMatchTradeRoute('swap')
const hooksMatch = !!useMatchTradeRoute('swap/hooks')
const limitOrderMatch = !!useMatchTradeRoute('limit')
const advancedOrdersMatch = !!useMatchTradeRoute('advanced')

return useMemo(() => {
if (hooksMatch) return { tradeType: TradeType.SWAP, route: Routes.HOOKS }
if (swapMatch) return { tradeType: TradeType.SWAP, route: Routes.SWAP }
if (limitOrderMatch) return { tradeType: TradeType.LIMIT_ORDER, route: Routes.LIMIT_ORDER }
if (advancedOrdersMatch) return { tradeType: TradeType.ADVANCED_ORDERS, route: Routes.ADVANCED_ORDERS }
Expand Down

0 comments on commit bab250c

Please sign in to comment.