Skip to content

Commit

Permalink
fix: broken dex link when not on dex app
Browse files Browse the repository at this point in the history
  • Loading branch information
Alunara committed Jan 28, 2025
1 parent bd3edfc commit 41f8503
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions apps/main/src/pages/dex.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { NextPage } from 'next'
import dynamic from 'next/dynamic'
import { Navigate, Route, Routes } from 'react-router'
import { Navigate, Route, Routes, useParams } from 'react-router'
import { REFRESH_INTERVAL, ROUTE } from '@/dex/constants'
import 'focus-visible'
import { i18n } from '@lingui/core'
Expand Down Expand Up @@ -158,9 +158,19 @@ const App: NextPage = () => {
isPageVisible,
)

/**
* Lazily use useParams() to preserve network parameter during redirects.
* Using Navigate instead of direct component rendering ensures proper
* menu highlighting via isActive state.
*/
const RootRedirect = () => {
const { network } = useParams()
return <Navigate to={`/${network}/pools`} />
}

const SubRoutes = (
<>
<Route path=":network/dashboard" element={<PageDashboard />} />
<Route path=":network" element={<RootRedirect />} />
<Route path=":network/locker" element={<PageLockedCrv />} />
<Route path=":network/locker/:lockedCrvFormType" element={<PageLockedCrv />} />
<Route path=":network/create-pool" element={<PageCreatePool />} />
Expand Down

0 comments on commit 41f8503

Please sign in to comment.