Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: broken dex link when not on dex app #650

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ?? 'ethereum'}/pools`} />
}

const SubRoutes = (
<>
<Route path=":network/dashboard" element={<PageDashboard />} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the dashboard removed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<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