Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
} from "constants/urls";
import { useV5DashboardChain } from "lib/v5-adapter";
import { getVercelEnv } from "lib/vercel-utils";
import { useMemo } from "react";
import { useTheme } from "next-themes";
import { useEffect, useMemo } from "react";
import { NATIVE_TOKEN_ADDRESS, createThirdwebClient, toTokens } from "thirdweb";
import { AutoConnect, PayEmbed } from "thirdweb/react";
import { setThirdwebDomains } from "thirdweb/utils";
Expand All @@ -35,8 +36,17 @@ export function CheckoutEmbed({
image?: string;
redirectUri?: string;
clientId: string;
theme: "light" | "dark";
theme?: "light" | "dark";
}) {
const { theme: browserTheme, setTheme } = useTheme();

// eslint-disable-next-line no-restricted-syntax
useEffect(() => {
if (theme) {
setTheme(theme);
}
}, [theme, setTheme]);

const client = useMemo(() => {
if (getVercelEnv() !== "production") {
setThirdwebDomains({
Expand All @@ -59,7 +69,7 @@ export function CheckoutEmbed({
<AutoConnect client={client} />
<PayEmbed
client={client}
theme={theme === "light" ? "light" : "dark"}
theme={theme ?? (browserTheme === "light" ? "light" : "dark")}
payOptions={{
metadata: {
name,
Expand Down

This file was deleted.

22 changes: 22 additions & 0 deletions apps/dashboard/src/app/checkout/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use client";

import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";

export default function ErrorPage({
error,
}: {
error: Error & { digest?: string };
}) {
return (
<Card className="overflow-hidden text-center">
<CardHeader className="border-b md:border-b-0">
<CardTitle className="font-bold text-destructive text-lg">
Something went wrong
</CardTitle>
</CardHeader>
<CardContent className="text-muted-foreground">
{error.message}
</CardContent>
</Card>
);
}
21 changes: 14 additions & 7 deletions apps/dashboard/src/app/checkout/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import "../../global.css";
import { cn } from "@/lib/utils";
import { ThemeProvider } from "next-themes";
import { Inter } from "next/font/google";
import { Suspense } from "react";
import { Providers } from "./components/client/Providers.client";
import { ThemeHandler } from "./components/client/ThemeHandler.client";

const fontSans = Inter({
subsets: ["latin"],
Expand All @@ -27,14 +26,22 @@ export default async function CheckoutLayout({
>
<body
className={cn(
"bg-background font-sans antialiased",
"h-screen w-screen bg-background font-sans antialiased",
fontSans.variable,
)}
>
<Suspense>
<ThemeHandler />
</Suspense>
{children}
<div className="relative mx-auto flex h-full w-full flex-col items-center justify-center overflow-hidden border py-10">
<main className="container z-10 flex justify-center">
{children}
</main>

{/* eslint-disable-next-line @next/next/no-img-element */}
<img
alt=""
src="/assets/login/background.svg"
className="-bottom-12 -right-12 pointer-events-none absolute lg:right-0 lg:bottom-0"
/>
</div>
</body>
</ThemeProvider>
</Providers>
Expand Down
34 changes: 11 additions & 23 deletions apps/dashboard/src/app/checkout/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "../../global.css";
import { getThirdwebClient } from "@/constants/thirdweb.server";
import type { Metadata } from "next";
import { createThirdwebClient, defineChain, getContract } from "thirdweb";
Expand Down Expand Up @@ -71,27 +70,16 @@ export default async function RoutesPage({
};

return (
<div className="relative mx-auto flex h-screen w-screen flex-col items-center justify-center overflow-hidden border py-10">
<main className="container z-10 flex justify-center">
<CheckoutEmbed
redirectUri={params.redirectUri}
chainId={Number(params.chainId)}
recipientAddress={params.recipientAddress}
amount={BigInt(params.amount)}
token={token}
clientId={client.clientId}
name={params.name}
image={params.image}
theme={params.theme === "light" ? "light" : "dark"}
/>
</main>

{/* eslint-disable-next-line @next/next/no-img-element */}
<img
alt=""
src="/assets/login/background.svg"
className="-bottom-12 -right-12 pointer-events-none absolute lg:right-0 lg:bottom-0"
/>
</div>
<CheckoutEmbed
redirectUri={params.redirectUri}
chainId={Number(params.chainId)}
recipientAddress={params.recipientAddress}
amount={BigInt(params.amount)}
token={token}
clientId={client.clientId}
name={params.name}
image={params.image}
theme={params.theme}
/>
);
}
Loading