Skip to content

Commit 9634e49

Browse files
committed
Feature: Add client id to checkout form url (#6997)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on enhancing the `CheckoutLinkForm` component by passing a `client` prop to it and improving its functionality. It also refines the styling and class management using the `cn` utility for better readability and maintainability. ### Detailed summary - Modified `page.tsx` to create a `client` using `getClientThirdwebClient` and pass it to `CheckoutLinkForm`. - Changed the `CheckoutLinkForm` function signature to accept a `client` prop. - Updated multiple instances in `CheckoutLinkForm` to utilize `client.clientId`. - Replaced static class names with the `cn` utility for dynamic class management in the button and div elements. - Adjusted the conditional rendering of classes for better readability and performance in the component. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent a4e12c5 commit 9634e49

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

apps/dashboard/src/app/checkout/components/client/CheckoutLinkForm.client.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Button } from "@/components/ui/button";
66
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
77
import { Input } from "@/components/ui/input";
88
import { Label } from "@/components/ui/label";
9-
import { useThirdwebClient } from "@/constants/thirdweb.client";
9+
import { cn } from "@/lib/utils";
1010
import { ChevronDownIcon, CreditCardIcon } from "lucide-react";
1111
import { useCallback, useMemo, useState } from "react";
1212
import { toast } from "sonner";
@@ -21,8 +21,7 @@ import { resolveScheme, upload } from "thirdweb/storage";
2121
import { FileInput } from "../../../../components/shared/FileInput";
2222
import { resolveEns } from "../../../../lib/ens";
2323

24-
export function CheckoutLinkForm() {
25-
const client = useThirdwebClient();
24+
export function CheckoutLinkForm({ client }: { client: ThirdwebClient }) {
2625
const [chainId, setChainId] = useState<number>();
2726
const [recipientAddress, setRecipientAddress] = useState("");
2827
const [tokenAddressWithChain, setTokenAddressWithChain] = useState("");
@@ -99,6 +98,7 @@ export function CheckoutLinkForm() {
9998
recipientAddress: inputs.recipientAddress,
10099
tokenAddress: inputs.tokenAddress,
101100
amount: inputs.amount.toString(),
101+
clientId: client.clientId,
102102
});
103103

104104
// Add title as name parameter if provided
@@ -155,6 +155,7 @@ export function CheckoutLinkForm() {
155155
recipientAddress: inputs.recipientAddress,
156156
tokenAddress: inputs.tokenAddress,
157157
amount: inputs.amount.toString(),
158+
clientId: client.clientId,
158159
});
159160

160161
// Add title as name parameter if provided
@@ -256,7 +257,9 @@ export function CheckoutLinkForm() {
256257
<Button
257258
type="button"
258259
variant="ghost"
259-
className="flex w-full items-center justify-between px-0 text-muted-foreground hover:bg-transparent"
260+
className={cn(
261+
"flex w-full items-center justify-between px-0 text-muted-foreground hover:bg-transparent",
262+
)}
260263
onClick={() => setShowAdvanced(!showAdvanced)}
261264
>
262265
<span>Advanced Options</span>
@@ -268,13 +271,14 @@ export function CheckoutLinkForm() {
268271
</Button>
269272

270273
<div
271-
className={`grid transition-all duration-200 ease-in-out ${
274+
className={cn(
275+
"grid transition-all duration-200 ease-in-out",
272276
showAdvanced
273277
? "grid-rows-[1fr] opacity-100"
274-
: "grid-rows-[0fr] opacity-0"
275-
}`}
278+
: "grid-rows-[0fr] opacity-0",
279+
)}
276280
>
277-
<div className="overflow-hidden">
281+
<div className={cn(showAdvanced ? "" : "overflow-hidden")}>
278282
<div className="space-y-6 pt-2">
279283
<div className="space-y-2">
280284
<Label htmlFor="title" className="font-medium text-sm">
@@ -293,7 +297,7 @@ export function CheckoutLinkForm() {
293297
<Label htmlFor="image" className="font-medium text-sm">
294298
Image
295299
</Label>
296-
<div className="w-full px-1 pb-1">
300+
<div className="w-full">
297301
<FileInput
298302
accept={{ "image/*": [] }}
299303
setValue={handleImageUpload}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ export default async function RoutesPage({
4040
return loginRedirect(`/checkout?${searchParams.toString()}`);
4141
}
4242

43-
return <CheckoutLinkForm />;
43+
const client = getClientThirdwebClient({
44+
jwt: authToken,
45+
teamId: undefined,
46+
});
47+
48+
return <CheckoutLinkForm client={client} />;
4449
}
4550

4651
// Validate query parameters

0 commit comments

Comments
 (0)