Skip to content

Commit 53b761b

Browse files
committed
fix: checkout error boundary
1 parent dfa3ee0 commit 53b761b

File tree

3 files changed

+50
-22
lines changed

3 files changed

+50
-22
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"use client"; // Error boundaries must be Client Components
2+
3+
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
4+
import { useEffect } from "react";
5+
6+
export default function ErrorPage({
7+
error,
8+
}: {
9+
error: Error & { digest?: string };
10+
}) {
11+
useEffect(() => {
12+
// Log the error to an error reporting service
13+
console.error(error);
14+
}, [error]);
15+
16+
return (
17+
<Card className="overflow-hidden text-center">
18+
<CardHeader className="border-b md:border-b-0">
19+
<CardTitle className="font-bold text-destructive text-lg">
20+
Something went wrong
21+
</CardTitle>
22+
</CardHeader>
23+
<CardContent className="text-muted-foreground">
24+
{error.message}
25+
</CardContent>
26+
</Card>
27+
);
28+
}

apps/dashboard/src/app/checkout/layout.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "../../global.css";
12
import { cn } from "@/lib/utils";
23
import { ThemeProvider } from "next-themes";
34
import { Inter } from "next/font/google";
@@ -23,11 +24,22 @@ export default function CheckoutLayout({
2324
>
2425
<body
2526
className={cn(
26-
"bg-background font-sans antialiased",
27+
"h-screen w-screen bg-background font-sans antialiased",
2728
fontSans.variable,
2829
)}
2930
>
30-
{children}
31+
<div className="relative mx-auto flex h-full w-full flex-col items-center justify-center overflow-hidden border py-10">
32+
<main className="container z-10 flex justify-center">
33+
{children}
34+
</main>
35+
36+
{/* eslint-disable-next-line @next/next/no-img-element */}
37+
<img
38+
alt=""
39+
src="/assets/login/background.svg"
40+
className="-bottom-12 -right-12 pointer-events-none absolute lg:right-0 lg:bottom-0"
41+
/>
42+
</div>
3143
</body>
3244
</ThemeProvider>
3345
</Providers>

apps/dashboard/src/app/checkout/page.tsx

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import "../../global.css";
21
import { getThirdwebClient } from "@/constants/thirdweb.server";
32
import type { Metadata } from "next";
43
import { createThirdwebClient, defineChain, getContract } from "thirdweb";
@@ -73,24 +72,13 @@ export default async function RoutesPage({
7372
};
7473

7574
return (
76-
<div className="relative mx-auto flex h-screen w-screen flex-col items-center justify-center overflow-hidden border py-10">
77-
<main className="container z-10 flex justify-center">
78-
<CheckoutEmbed
79-
redirectUri={redirectUri}
80-
chainId={Number(chainId)}
81-
recipientAddress={recipientAddress}
82-
amount={BigInt(amount)}
83-
token={token}
84-
clientId={client.clientId}
85-
/>
86-
</main>
87-
88-
{/* eslint-disable-next-line @next/next/no-img-element */}
89-
<img
90-
alt=""
91-
src="/assets/login/background.svg"
92-
className="-bottom-12 -right-12 pointer-events-none absolute lg:right-0 lg:bottom-0"
93-
/>
94-
</div>
75+
<CheckoutEmbed
76+
redirectUri={redirectUri}
77+
chainId={Number(chainId)}
78+
recipientAddress={recipientAddress}
79+
amount={BigInt(amount)}
80+
token={token}
81+
clientId={client.clientId}
82+
/>
9583
);
9684
}

0 commit comments

Comments
 (0)