Skip to content

Commit 04018ab

Browse files
committed
fix token fetching
1 parent 6713fe8 commit 04018ab

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

apps/dashboard/src/@/components/blocks/TokenSelector.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useCallback, useMemo } from "react";
22
import type { ThirdwebClient } from "thirdweb";
3+
import { shortenAddress } from "thirdweb/utils";
34
import { useTokensData } from "../../../hooks/tokens/tokens";
45
import { replaceIpfsUrl } from "../../../lib/sdk";
56
import { fallbackChainIcon } from "../../../utils/chain-icons";
@@ -89,8 +90,8 @@ export function TokenSelector(props: {
8990

9091
{!props.disableChainId && (
9192
<Badge variant="outline" className="gap-2 max-sm:hidden">
92-
<span className="text-muted-foreground">Chain ID</span>
93-
{token.chainId}
93+
<span className="text-muted-foreground">Address</span>
94+
{shortenAddress(token.address, 4)}
9495
</Badge>
9596
)}
9697
</div>

apps/dashboard/src/@/components/blocks/select-with-search.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export const SelectWithSearch = React.forwardRef<
128128
<span
129129
className={cn(
130130
"truncate text-muted-foreground text-sm",
131-
selectedOption && "text-foreground",
131+
selectedOption && "w-full text-foreground",
132132
)}
133133
>
134134
{renderOption && selectedOption

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Input } from "@/components/ui/input";
88
import { Label } from "@/components/ui/label";
99
import { useThirdwebClient } from "@/constants/thirdweb.client";
1010
import { CreditCardIcon } from "lucide-react";
11-
import { useState } from "react";
11+
import { useMemo, useState } from "react";
1212
import { toast } from "sonner";
1313
import { type ThirdwebClient, defineChain, getContract } from "thirdweb";
1414
import { getCurrencyMetadata } from "thirdweb/extensions/erc20";
@@ -23,6 +23,10 @@ export function CheckoutLinkForm() {
2323
const [isLoading, setIsLoading] = useState(false);
2424
const [error, setError] = useState<string>();
2525

26+
const isFormComplete = useMemo(() => {
27+
return chainId && recipientAddress && tokenAddressWithChain && amount;
28+
}, [chainId, recipientAddress, tokenAddressWithChain, amount]);
29+
2630
const handleSubmit = async (e: React.FormEvent) => {
2731
e.preventDefault();
2832
setError(undefined);
@@ -141,6 +145,7 @@ export function CheckoutLinkForm() {
141145
type="button"
142146
variant="outline"
143147
className="flex-1"
148+
disabled={isLoading || !isFormComplete}
144149
onClick={async () => {
145150
if (
146151
!chainId ||
@@ -169,7 +174,11 @@ export function CheckoutLinkForm() {
169174
>
170175
Preview
171176
</Button>
172-
<Button type="submit" className="flex-1" disabled={isLoading}>
177+
<Button
178+
type="submit"
179+
className="flex-1"
180+
disabled={isLoading || !isFormComplete}
181+
>
173182
{isLoading ? "Creating..." : "Create"}
174183
</Button>
175184
</div>

apps/dashboard/src/hooks/tokens/tokens.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ export function useTokensData({
9494

9595
// eslint-disable-next-line no-restricted-syntax
9696
useEffect(() => {
97-
// already set
98-
if (tokensStore.getValue().length > 0) {
99-
return;
100-
}
101-
10297
if (!tokensQuery.data) {
10398
return;
10499
}

0 commit comments

Comments
 (0)