Skip to content

Commit c585184

Browse files
joaquim-vergesMananTank
authored andcommitted
[Dashboard] Fix asset page link and improve token claim UX (#7193)
1 parent 51eda91 commit c585184

File tree

6 files changed

+28
-13
lines changed

6 files changed

+28
-13
lines changed

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/overview/ContractOverviewPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const ContractOverviewPage: React.FC<ContractOverviewPageProps> = ({
5353
text: "View asset page",
5454
icon: <ExternalLinkIcon className="size-4" />,
5555
target: "_blank",
56-
link: `https://thirdweb.com/${chainSlug}/${contract.address}`,
56+
link: `/${chainSlug}/${contract.address}`,
5757
}}
5858
trackingCategory="erc20-contract"
5959
trackingLabel="view-asset-page"

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_components/claim-tokens/claim-tokens-ui.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ export function ClaimTokenCardUI(props: {
122122
}
123123

124124
async function sendAndConfirm() {
125-
const receipt = await sendClaimTx.mutateAsync(transaction);
126-
await waitForReceipt(receipt);
125+
const result = await sendClaimTx.mutateAsync(transaction);
126+
await waitForReceipt(result);
127127
}
128128

129129
setStepsUI({
@@ -204,12 +204,6 @@ export function ClaimTokenCardUI(props: {
204204

205205
const claimParamsData = claimParamsQuery.data;
206206

207-
const totalPriceInTokens = claimParamsData
208-
? Number(
209-
toTokens(claimParamsData.pricePerTokenWei, claimParamsData.decimals),
210-
) * quantity
211-
: undefined;
212-
213207
return (
214208
<div className="rounded-xl border bg-card ">
215209
<div className="border-b px-4 py-5 lg:px-5">
@@ -269,8 +263,15 @@ export function ClaimTokenCardUI(props: {
269263
<SkeletonContainer
270264
skeletonData={"0.00 ETH"}
271265
loadedData={
272-
totalPriceInTokens && claimParamsData
273-
? `${totalPriceInTokens} ${claimParamsData.symbol}`
266+
claimParamsData
267+
? `${
268+
Number(
269+
toTokens(
270+
claimParamsData.pricePerTokenWei,
271+
claimParamsData.decimals,
272+
),
273+
) * quantity
274+
} ${claimParamsData.symbol}`
274275
: undefined
275276
}
276277
render={(v) => {
@@ -286,6 +287,7 @@ export function ClaimTokenCardUI(props: {
286287
{account ? (
287288
<TransactionButton
288289
transactionCount={undefined}
290+
checkBalance={false}
289291
isLoggedIn={true}
290292
isPending={approveAndClaim.isPending}
291293
onClick={async () => {

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_hooks/useTokenPriceData.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@ export function useTokenPriceData(params: {
5151
}
5252
: { type: "no-data" as const };
5353
},
54+
refetchInterval: 5000,
5455
});
5556
}

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_hooks/useTokenTransfers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ export function useTokenTransfers(params: {
4949
const data = json.data as TokenTransfersData[];
5050
return data;
5151
},
52+
refetchInterval: 5000,
5253
});
5354
}

apps/dashboard/src/components/buttons/MismatchButton.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,20 @@ type MistmatchButtonProps = React.ComponentProps<typeof Button> & {
8080
txChainId: number;
8181
isLoggedIn: boolean;
8282
isPending: boolean;
83+
checkBalance?: boolean;
8384
};
8485

8586
export const MismatchButton = forwardRef<
8687
HTMLButtonElement,
8788
MistmatchButtonProps
8889
>((props, ref) => {
89-
const { txChainId, isLoggedIn, isPending, ...buttonProps } = props;
90+
const {
91+
txChainId,
92+
isLoggedIn,
93+
isPending,
94+
checkBalance = true,
95+
...buttonProps
96+
} = props;
9097
const account = useActiveAccount();
9198
const wallet = useActiveWallet();
9299
const activeWalletChain = useActiveWalletChain();
@@ -150,7 +157,8 @@ export const MismatchButton = forwardRef<
150157
}
151158

152159
const isBalanceRequired =
153-
wallet.id === "smart" ? false : !GAS_FREE_CHAINS.includes(txChainId);
160+
checkBalance &&
161+
(wallet.id === "smart" ? false : !GAS_FREE_CHAINS.includes(txChainId));
154162

155163
const notEnoughBalance =
156164
(txChainBalance.data?.value || 0n) === 0n && isBalanceRequired;

apps/dashboard/src/components/buttons/TransactionButton.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type TransactionButtonProps = Omit<ButtonProps, "variant"> & {
2929
txChainID: number;
3030
variant?: "destructive" | "primary" | "default";
3131
isLoggedIn: boolean;
32+
checkBalance?: boolean;
3233
};
3334

3435
export const TransactionButton: React.FC<TransactionButtonProps> = ({
@@ -38,6 +39,7 @@ export const TransactionButton: React.FC<TransactionButtonProps> = ({
3839
txChainID,
3940
variant,
4041
isLoggedIn,
42+
checkBalance,
4143
...restButtonProps
4244
}) => {
4345
const activeWallet = useActiveWallet();
@@ -68,6 +70,7 @@ export const TransactionButton: React.FC<TransactionButtonProps> = ({
6870
txChainId={txChainID}
6971
{...restButtonProps}
7072
disabled={disabled}
73+
checkBalance={checkBalance}
7174
className={cn("relative overflow-hidden", restButtonProps.className)}
7275
style={{
7376
paddingLeft: transactionCount

0 commit comments

Comments
 (0)