From d0be202fb5f562745230bfbff5f00aa1e1c38893 Mon Sep 17 00:00:00 2001 From: Daniel Schiavini Date: Mon, 11 Aug 2025 12:54:45 +0200 Subject: [PATCH 1/2] refactor: fix nextjs imports --- apps/main/src/app/StyledComponentsRegistry.tsx | 2 +- apps/main/src/app/crvusd/client.tsx | 2 +- apps/main/src/app/dao/layout.tsx | 2 +- apps/main/src/app/dex/[network]/layout.tsx | 2 +- apps/main/src/app/dex/layout.tsx | 2 +- apps/main/src/app/lend/layout.tsx | 2 +- .../src/dao/components/PageAnalytics/CrvStats/index.tsx | 4 +--- apps/main/src/dex/components/PagePool/index.tsx | 4 ++-- packages/curve-ui-kit/src/hooks/router.ts | 4 ++-- packages/curve-ui-kit/src/shared/icons/ArbitrageIcon.tsx | 8 ++++---- packages/curve-ui-kit/src/shared/icons/MarketTypeIcon.tsx | 6 +++--- .../curve-ui-kit/src/shared/icons/RebalancingIcon.tsx | 2 +- tests/tsconfig.json | 1 + tests/vite.config.ts | 1 + 14 files changed, 21 insertions(+), 21 deletions(-) diff --git a/apps/main/src/app/StyledComponentsRegistry.tsx b/apps/main/src/app/StyledComponentsRegistry.tsx index 0e923f3e4c..81b2035e31 100644 --- a/apps/main/src/app/StyledComponentsRegistry.tsx +++ b/apps/main/src/app/StyledComponentsRegistry.tsx @@ -1,5 +1,5 @@ 'use client' -import { useServerInsertedHTML } from 'next/navigation' +import { useServerInsertedHTML } from '@ui-kit/hooks/router' import { ReactNode, useState } from 'react' import { ServerStyleSheet, StyleSheetManager } from 'styled-components' import { shouldForwardProp } from '@ui/styled-containers' diff --git a/apps/main/src/app/crvusd/client.tsx b/apps/main/src/app/crvusd/client.tsx index 0cb6cce1c5..45fc62cc7e 100644 --- a/apps/main/src/app/crvusd/client.tsx +++ b/apps/main/src/app/crvusd/client.tsx @@ -1,6 +1,6 @@ 'use client' import '@/global-extensions' -import { useParams } from 'next/navigation' +import { useParams } from '@ui-kit/hooks/router' import { type ReactNode, useEffect } from 'react' import type { CrvUsdServerData } from '@/app/api/crvusd/types' import { setAppStatsDailyVolume } from '@/loan/entities/appstats-daily-volume' diff --git a/apps/main/src/app/dao/layout.tsx b/apps/main/src/app/dao/layout.tsx index c2af4c86b9..2cbcc70860 100644 --- a/apps/main/src/app/dao/layout.tsx +++ b/apps/main/src/app/dao/layout.tsx @@ -1,6 +1,6 @@ 'use client' import '@/global-extensions' -import { useParams } from 'next/navigation' +import { useParams } from '@ui-kit/hooks/router' import { type ReactNode } from 'react' import networks, { networksIdMapper } from '@/dao/networks' import useStore from '@/dao/store/useStore' diff --git a/apps/main/src/app/dex/[network]/layout.tsx b/apps/main/src/app/dex/[network]/layout.tsx index 7eafa85db6..a85adb6214 100644 --- a/apps/main/src/app/dex/[network]/layout.tsx +++ b/apps/main/src/app/dex/[network]/layout.tsx @@ -1,5 +1,5 @@ import { headers } from 'next/headers' -import { notFound } from 'next/navigation' +import { notFound } from '@ui-kit/hooks/router' import type { ReactNode } from 'react' import type { DexServerSideNetworkCache } from '@/app/api/dex/types' import { getServerData } from '@/background' diff --git a/apps/main/src/app/dex/layout.tsx b/apps/main/src/app/dex/layout.tsx index 37d88f2325..1e88aeba9f 100644 --- a/apps/main/src/app/dex/layout.tsx +++ b/apps/main/src/app/dex/layout.tsx @@ -1,6 +1,6 @@ 'use client' import '@/global-extensions' -import { useParams } from 'next/navigation' +import { useParams } from '@ui-kit/hooks/router' import { type ReactNode, use, useCallback, useEffect, useState } from 'react' import curvejsApi from '@/dex/lib/curvejs' import { getNetworkDefs } from '@/dex/lib/networks' diff --git a/apps/main/src/app/lend/layout.tsx b/apps/main/src/app/lend/layout.tsx index ce837e34b5..9c984a116a 100644 --- a/apps/main/src/app/lend/layout.tsx +++ b/apps/main/src/app/lend/layout.tsx @@ -1,6 +1,6 @@ 'use client' import '@/global-extensions' -import { useParams } from 'next/navigation' +import { useParams } from '@ui-kit/hooks/router' import { type ReactNode } from 'react' import networks, { networksIdMapper } from '@/lend/networks' import useStore from '@/lend/store/useStore' diff --git a/apps/main/src/dao/components/PageAnalytics/CrvStats/index.tsx b/apps/main/src/dao/components/PageAnalytics/CrvStats/index.tsx index 544c1a2e9a..bc7a4bc36e 100644 --- a/apps/main/src/dao/components/PageAnalytics/CrvStats/index.tsx +++ b/apps/main/src/dao/components/PageAnalytics/CrvStats/index.tsx @@ -92,9 +92,7 @@ const CrvStats = () => { value={noProvider || !statsSuccess ? null : veCrvApr.current} valueOptions={{ unit: 'percentage', decimals: 2 }} notional={ - Boolean(loading || veCrvFeesLoading || aprLoading) - ? undefined - : `${veCrvApr.fourDayAverage.toFixed(2)}% 4w avg` + loading || veCrvFeesLoading || aprLoading ? undefined : `${veCrvApr.fourDayAverage.toFixed(2)}% 4w avg` } /> diff --git a/apps/main/src/dex/components/PagePool/index.tsx b/apps/main/src/dex/components/PagePool/index.tsx index a5e0598b58..b3a932a3a4 100644 --- a/apps/main/src/dex/components/PagePool/index.tsx +++ b/apps/main/src/dex/components/PagePool/index.tsx @@ -93,12 +93,12 @@ const Transfer = (pageTransferProps: PageTransferProps) => { const { data: gaugeManager, isPending: isPendingGaugeManager } = useGaugeManager({ chainId: rChainId, - poolId: poolData?.pool.id!, + poolId: poolData?.pool.id, }) const { data: rewardDistributors, isPending: isPendingRewardsDistributors } = useGaugeRewardsDistributors({ chainId: rChainId, - poolId: poolData?.pool.id!, + poolId: poolData?.pool.id, }) const [selectedTab, setSelectedTab] = useState('pool') diff --git a/packages/curve-ui-kit/src/hooks/router.ts b/packages/curve-ui-kit/src/hooks/router.ts index 010bcdd481..a7c4c11a66 100644 --- a/packages/curve-ui-kit/src/hooks/router.ts +++ b/packages/curve-ui-kit/src/hooks/router.ts @@ -1,7 +1,7 @@ -import { useRouter, useSearchParams as useOriginalSearchParams } from 'next/navigation' import { useCallback } from 'react' +import { useRouter, useSearchParams as useOriginalSearchParams } from '@ui-kit/hooks/router' -export { useParams, usePathname } from 'next/navigation' +export { useParams, usePathname } from '@ui-kit/hooks/router' export const useNavigate = () => { const { push, replace } = useRouter() diff --git a/packages/curve-ui-kit/src/shared/icons/ArbitrageIcon.tsx b/packages/curve-ui-kit/src/shared/icons/ArbitrageIcon.tsx index ed4465ec5b..6d061af61d 100644 --- a/packages/curve-ui-kit/src/shared/icons/ArbitrageIcon.tsx +++ b/packages/curve-ui-kit/src/shared/icons/ArbitrageIcon.tsx @@ -11,14 +11,14 @@ export const ArbitrageIcon = createSvgIcon( , 'MarketType', diff --git a/packages/curve-ui-kit/src/shared/icons/RebalancingIcon.tsx b/packages/curve-ui-kit/src/shared/icons/RebalancingIcon.tsx index 6d855ce496..f54fcafbc3 100644 --- a/packages/curve-ui-kit/src/shared/icons/RebalancingIcon.tsx +++ b/packages/curve-ui-kit/src/shared/icons/RebalancingIcon.tsx @@ -10,7 +10,7 @@ export const RebalancingIcon = createSvgIcon( d="M37 20C37 20.5523 36.5523 21 36 21H14C13.4477 21 13 20.5523 13 20V10C13 9.44772 13.4477 9 14 9H36C36.5523 9 37 9.44772 37 10V20ZM20 12C18.3431 12 17 13.3431 17 15C17 16.6569 18.3431 18 20 18C21.6569 18 23 16.6569 23 15C23 13.3431 21.6569 12 20 12ZM30 12C28.3431 12 27 13.3431 27 15C27 16.6569 28.3431 18 30 18C31.6569 18 33 16.6569 33 15C33 13.3431 31.6569 12 30 12Z" fill="currentcolor" /> - + Date: Mon, 11 Aug 2025 14:45:27 +0200 Subject: [PATCH 2/2] fix: build --- apps/main/src/app/GlobalLayout.tsx | 2 +- apps/main/src/app/StyledComponentsRegistry.tsx | 2 +- apps/main/src/app/crvusd/client.tsx | 2 +- apps/main/src/app/dao/layout.tsx | 2 +- apps/main/src/app/dex/[network]/layout.tsx | 2 +- apps/main/src/app/dex/layout.tsx | 2 +- apps/main/src/app/lend/layout.tsx | 2 +- packages/curve-ui-kit/src/hooks/router.ts | 4 ++-- packages/curve-ui-kit/src/widgets/Header/MobileHeader.tsx | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/main/src/app/GlobalLayout.tsx b/apps/main/src/app/GlobalLayout.tsx index 5be656142e..e7f2d08fab 100644 --- a/apps/main/src/app/GlobalLayout.tsx +++ b/apps/main/src/app/GlobalLayout.tsx @@ -1,3 +1,4 @@ +import NextTopLoader from 'nextjs-toploader' import { type ReactNode } from 'react' import daoNetworks from '@/dao/networks' import { useDexAppStats, useDexRoutes } from '@/dex/hooks/useDexAppStats' @@ -14,7 +15,6 @@ import { APP_LINK, AppMenuOption, type AppName } from '@ui-kit/shared/routes' import { SizesAndSpaces } from '@ui-kit/themes/design/1_sizes_spaces' import { Footer } from '@ui-kit/widgets/Footer' import { Header as Header } from '@ui-kit/widgets/Header' -import NextTopLoader from 'nextjs-toploader' const { MinHeight } = SizesAndSpaces diff --git a/apps/main/src/app/StyledComponentsRegistry.tsx b/apps/main/src/app/StyledComponentsRegistry.tsx index 81b2035e31..0e923f3e4c 100644 --- a/apps/main/src/app/StyledComponentsRegistry.tsx +++ b/apps/main/src/app/StyledComponentsRegistry.tsx @@ -1,5 +1,5 @@ 'use client' -import { useServerInsertedHTML } from '@ui-kit/hooks/router' +import { useServerInsertedHTML } from 'next/navigation' import { ReactNode, useState } from 'react' import { ServerStyleSheet, StyleSheetManager } from 'styled-components' import { shouldForwardProp } from '@ui/styled-containers' diff --git a/apps/main/src/app/crvusd/client.tsx b/apps/main/src/app/crvusd/client.tsx index 45fc62cc7e..4d0a22aec4 100644 --- a/apps/main/src/app/crvusd/client.tsx +++ b/apps/main/src/app/crvusd/client.tsx @@ -1,6 +1,5 @@ 'use client' import '@/global-extensions' -import { useParams } from '@ui-kit/hooks/router' import { type ReactNode, useEffect } from 'react' import type { CrvUsdServerData } from '@/app/api/crvusd/types' import { setAppStatsDailyVolume } from '@/loan/entities/appstats-daily-volume' @@ -8,6 +7,7 @@ import { networks, networksIdMapper } from '@/loan/networks' import useStore from '@/loan/store/useStore' import type { UrlParams } from '@/loan/types/loan.types' import { recordValues } from '@curvefi/prices-api/objects.util' +import { useParams } from '@ui-kit/hooks/router' import { useHydration } from '@ui-kit/hooks/useHydration' import { useRedirectToEth } from '@ui-kit/hooks/useRedirectToEth' import { logSuccess } from '@ui-kit/lib' diff --git a/apps/main/src/app/dao/layout.tsx b/apps/main/src/app/dao/layout.tsx index 2cbcc70860..95d9f33f84 100644 --- a/apps/main/src/app/dao/layout.tsx +++ b/apps/main/src/app/dao/layout.tsx @@ -1,11 +1,11 @@ 'use client' import '@/global-extensions' -import { useParams } from '@ui-kit/hooks/router' import { type ReactNode } from 'react' import networks, { networksIdMapper } from '@/dao/networks' import useStore from '@/dao/store/useStore' import { type UrlParams } from '@/dao/types/dao.types' import { useLayoutStore } from '@ui-kit/features/layout' +import { useParams } from '@ui-kit/hooks/router' import { useHydration } from '@ui-kit/hooks/useHydration' import usePageVisibleInterval from '@ui-kit/hooks/usePageVisibleInterval' import { useRedirectToEth } from '@ui-kit/hooks/useRedirectToEth' diff --git a/apps/main/src/app/dex/[network]/layout.tsx b/apps/main/src/app/dex/[network]/layout.tsx index a85adb6214..7eafa85db6 100644 --- a/apps/main/src/app/dex/[network]/layout.tsx +++ b/apps/main/src/app/dex/[network]/layout.tsx @@ -1,5 +1,5 @@ import { headers } from 'next/headers' -import { notFound } from '@ui-kit/hooks/router' +import { notFound } from 'next/navigation' import type { ReactNode } from 'react' import type { DexServerSideNetworkCache } from '@/app/api/dex/types' import { getServerData } from '@/background' diff --git a/apps/main/src/app/dex/layout.tsx b/apps/main/src/app/dex/layout.tsx index 1e88aeba9f..dc1728b8b9 100644 --- a/apps/main/src/app/dex/layout.tsx +++ b/apps/main/src/app/dex/layout.tsx @@ -1,6 +1,5 @@ 'use client' import '@/global-extensions' -import { useParams } from '@ui-kit/hooks/router' import { type ReactNode, use, useCallback, useEffect, useState } from 'react' import curvejsApi from '@/dex/lib/curvejs' import { getNetworkDefs } from '@/dex/lib/networks' @@ -11,6 +10,7 @@ import { recordValues } from '@curvefi/prices-api/objects.util' import type { NetworkDef } from '@ui/utils' import { useConnection } from '@ui-kit/features/connect-wallet' import { useLayoutStore } from '@ui-kit/features/layout' +import { useParams } from '@ui-kit/hooks/router' import { useHydration } from '@ui-kit/hooks/useHydration' import usePageVisibleInterval from '@ui-kit/hooks/usePageVisibleInterval' import { useRedirectToEth } from '@ui-kit/hooks/useRedirectToEth' diff --git a/apps/main/src/app/lend/layout.tsx b/apps/main/src/app/lend/layout.tsx index 9c984a116a..687e99e33a 100644 --- a/apps/main/src/app/lend/layout.tsx +++ b/apps/main/src/app/lend/layout.tsx @@ -1,10 +1,10 @@ 'use client' import '@/global-extensions' -import { useParams } from '@ui-kit/hooks/router' import { type ReactNode } from 'react' import networks, { networksIdMapper } from '@/lend/networks' import useStore from '@/lend/store/useStore' import type { UrlParams } from '@/lend/types/lend.types' +import { useParams } from '@ui-kit/hooks/router' import { useHydration } from '@ui-kit/hooks/useHydration' import { useRedirectToEth } from '@ui-kit/hooks/useRedirectToEth' import { useGasInfoAndUpdateLib } from '@ui-kit/lib/model/entities/gas-info' diff --git a/packages/curve-ui-kit/src/hooks/router.ts b/packages/curve-ui-kit/src/hooks/router.ts index a7c4c11a66..010bcdd481 100644 --- a/packages/curve-ui-kit/src/hooks/router.ts +++ b/packages/curve-ui-kit/src/hooks/router.ts @@ -1,7 +1,7 @@ +import { useRouter, useSearchParams as useOriginalSearchParams } from 'next/navigation' import { useCallback } from 'react' -import { useRouter, useSearchParams as useOriginalSearchParams } from '@ui-kit/hooks/router' -export { useParams, usePathname } from '@ui-kit/hooks/router' +export { useParams, usePathname } from 'next/navigation' export const useNavigate = () => { const { push, replace } = useRouter() diff --git a/packages/curve-ui-kit/src/widgets/Header/MobileHeader.tsx b/packages/curve-ui-kit/src/widgets/Header/MobileHeader.tsx index d2034f3f03..b6608fb3fa 100644 --- a/packages/curve-ui-kit/src/widgets/Header/MobileHeader.tsx +++ b/packages/curve-ui-kit/src/widgets/Header/MobileHeader.tsx @@ -6,6 +6,7 @@ import Stack from '@mui/material/Stack' import Toolbar from '@mui/material/Toolbar' import { useLayoutStore } from '@ui-kit/features/layout' import { usePathname } from '@ui-kit/hooks/router' +import { useBetaFlag } from '@ui-kit/hooks/useLocalStorage' import { t } from '@ui-kit/lib/i18n' import { APP_LINK, routeToPage } from '@ui-kit/shared/routes' import { GlobalBanner } from '@ui-kit/shared/ui/GlobalBanner' @@ -17,7 +18,6 @@ import { SidebarSection } from './SidebarSection' import { SocialSidebarSection } from './SocialSidebarSection' import { HeaderImplementationProps } from './types' import { useMainNavRef } from './useMainNavRef' -import { useBetaFlag } from '@ui-kit/hooks/useLocalStorage' const HIDE_SCROLLBAR = { // hide the scrollbar, on mobile it's not needed, and it messes up with the SideBarFooter