From 2ebba6139a3075fb786fd031822d162279169ef4 Mon Sep 17 00:00:00 2001 From: MananTank Date: Mon, 6 Oct 2025 19:51:08 +0000 Subject: [PATCH] [MNY-235] Dashboard: Fix payment page theme issues (#8199) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ## PR-Codex overview This PR focuses on integrating the `ThemeProvider` from `next-themes` into multiple components within the payment module, enhancing theming support across the application. ### Detailed summary - Removed `ThemeProvider` from `PayLayout` in `layout.tsx`. - Added `ThemeProvider` wrapping to `PayPage` in `page.tsx`. - Integrated `ThemeProvider` in `PayPageWidget` to manage theme settings. - Updated theme handling logic in `PayPageWidget` to use `getSDKTheme`. - Wrapped the main structure in `ThemeProvider` in `[id]/page.tsx`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` ## Summary by CodeRabbit - New Features - Consistent light/dark theme across all Pay pages, with support for forcing a theme per link and reduced visual flicker from system theme changes. - Style - Refined header layout: project image, name, and description grouped; “Secured by thirdweb” badge retained. - Improved details on large screens: clearer “Network” label with icon and chain name; seller shown as ENS or shortened address, reordered for readability. - Refactor - Consolidated theming at the page level for consistent behavior across views. --- apps/dashboard/src/app/pay/[id]/page.tsx | 235 +++++++++--------- .../client/PayPageWidget.client.tsx | 14 +- apps/dashboard/src/app/pay/layout.tsx | 14 +- apps/dashboard/src/app/pay/page.tsx | 42 +++- 4 files changed, 156 insertions(+), 149 deletions(-) diff --git a/apps/dashboard/src/app/pay/[id]/page.tsx b/apps/dashboard/src/app/pay/[id]/page.tsx index 239f1da201d..19a809bb5af 100644 --- a/apps/dashboard/src/app/pay/[id]/page.tsx +++ b/apps/dashboard/src/app/pay/[id]/page.tsx @@ -1,5 +1,6 @@ import { ShieldCheckIcon } from "lucide-react"; import type { Metadata } from "next"; +import { ThemeProvider } from "next-themes"; import { Bridge, defineChain, toTokens } from "thirdweb"; import { getChainMetadata } from "thirdweb/chains"; import { shortenAddress } from "thirdweb/utils"; @@ -80,131 +81,137 @@ export default async function PayPage({ } return ( -
-
-
-
- {projectMetadata.image && ( - {projectMetadata.name} + +
+
+
+
+ {projectMetadata.image && ( + {projectMetadata.name} + )} +

{projectMetadata.name}

+
+ {projectMetadata.description && ( +

+ {projectMetadata.description} +

)} -

{projectMetadata.name}

- {projectMetadata.description && ( -

- {projectMetadata.description} -

- )} -
-
- {paymentLink.amount && ( -
- Details -
-
- {token.iconUri && ( - {token.name} - )} - {toTokens(BigInt(paymentLink.amount), token.decimals)}{" "} - {token.symbol} -
- {token.prices.USD && ( - - $ - {( - Number(token.prices.USD) * - Number( - toTokens(BigInt(paymentLink.amount), token.decimals), - ) - ).toFixed(2)} - - )} -
-
- )} - {chain && ( -
- Network -
-
- {chain.icon?.url && ( - {chain.name} +
+ {paymentLink.amount && ( +
+ Details +
+
+ {token.iconUri && ( + {token.name} + )} + {toTokens(BigInt(paymentLink.amount), token.decimals)}{" "} + {token.symbol} +
+ {token.prices.USD && ( + + $ + {( + Number(token.prices.USD) * + Number( + toTokens(BigInt(paymentLink.amount), token.decimals), + ) + ).toFixed(2)} + )} - {chain.name}
-
- )} - {recipientEnsOrAddress.ensName || - (recipientEnsOrAddress.address && ( + )} + {chain && (
- Seller + Network
- {recipientEnsOrAddress.ensName ?? - shortenAddress(recipientEnsOrAddress.address)} +
+ {chain.icon?.url && ( + {chain.name} + )} + {chain.name} +
- ))} -
+ )} + {recipientEnsOrAddress.ensName || + (recipientEnsOrAddress.address && ( +
+ Seller +
+ {recipientEnsOrAddress.ensName ?? + shortenAddress(recipientEnsOrAddress.address)} +
+
+ ))} +
-
- - - Secured by thirdweb - -
-
-
- -
-
+
+ + + Secured by thirdweb + +
+ +
+ +
+ + ); } diff --git a/apps/dashboard/src/app/pay/components/client/PayPageWidget.client.tsx b/apps/dashboard/src/app/pay/components/client/PayPageWidget.client.tsx index 2cd71f91e08..c2b50f91b65 100644 --- a/apps/dashboard/src/app/pay/components/client/PayPageWidget.client.tsx +++ b/apps/dashboard/src/app/pay/components/client/PayPageWidget.client.tsx @@ -1,7 +1,6 @@ "use client"; import { payAppThirdwebClient } from "app/pay/constants"; import { useTheme } from "next-themes"; -import { useEffect } from "react"; import { createThirdwebClient, NATIVE_TOKEN_ADDRESS, toTokens } from "thirdweb"; import { AutoConnect, CheckoutWidget } from "thirdweb/react"; import { checksumAddress } from "thirdweb/utils"; @@ -11,6 +10,7 @@ import { reportPaymentLinkBuySuccessful, } from "@/analytics/report"; import { useV5DashboardChain } from "@/hooks/chains/v5-adapter"; +import { getSDKTheme } from "@/utils/sdk-component-theme"; export function PayPageWidget({ chainId, @@ -21,7 +21,6 @@ export function PayPageWidget({ name, image, redirectUri, - theme, purchaseData, clientId, }: { @@ -34,17 +33,10 @@ export function PayPageWidget({ image?: string; redirectUri?: string; clientId: string | undefined; - theme?: "light" | "dark"; purchaseData: Record | undefined; }) { - const { theme: browserTheme, setTheme } = useTheme(); + const { theme } = useTheme(); - // eslint-disable-next-line no-restricted-syntax - useEffect(() => { - if (theme) { - setTheme(theme); - } - }, [theme, setTheme]); const chain = useV5DashboardChain(chainId); return ( @@ -55,6 +47,7 @@ export function PayPageWidget({ } /> - -
- {children} -
-
+
+ {children} +
diff --git a/apps/dashboard/src/app/pay/page.tsx b/apps/dashboard/src/app/pay/page.tsx index 787741d3bdf..7e6d6e60e65 100644 --- a/apps/dashboard/src/app/pay/page.tsx +++ b/apps/dashboard/src/app/pay/page.tsx @@ -1,4 +1,5 @@ import type { Metadata } from "next"; +import { ThemeProvider } from "next-themes"; import { createThirdwebClient, defineChain, getContract } from "thirdweb"; import { getCurrencyMetadata } from "thirdweb/extensions/erc20"; import { checksumAddress } from "thirdweb/utils"; @@ -33,7 +34,16 @@ export default async function PayPage({ !params.tokenAddress && !params.amount ) { - return ; + return ( + + + + ); } // Validate query parameters @@ -84,17 +94,23 @@ export default async function PayPage({ }; return ( - + + + ); }