Skip to content

Commit e3a4173

Browse files
committed
[BLD-166] Dashboard: Show Manage Contract button if user has used dashboard
1 parent 6caba38 commit e3a4173

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

apps/dashboard/src/@/constants/cookie.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export const COOKIE_PREFIX_TOKEN = "tw_token_";
33

44
export const LAST_USED_PROJECT_ID = "last-used-project-id";
55
export const LAST_USED_TEAM_ID = "last-used-team-id";
6+
export const HAS_USED_DASHBOARD = "has-used-dashboard";

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import Link from "next/link";
99
import { useMemo } from "react";
1010
import { type ThirdwebContract, ZERO_ADDRESS } from "thirdweb";
1111
import type { ChainMetadata } from "thirdweb/chains";
12-
import { useActiveAccount } from "thirdweb/react";
1312
import { Img } from "@/components/blocks/Img";
1413
import { Button } from "@/components/ui/button";
1514
import { CopyAddressButton } from "@/components/ui/CopyAddressButton";
@@ -51,6 +50,7 @@ export function ContractHeaderUI(props: {
5150
imageClassName?: string;
5251
contractCreator: string | null;
5352
className?: string;
53+
isDashboardUser: boolean;
5454
}) {
5555
const socialUrls = useMemo(() => {
5656
const socialUrlsValue: { name: string; href: string }[] = [];
@@ -66,7 +66,6 @@ export function ContractHeaderUI(props: {
6666

6767
return socialUrlsValue;
6868
}, [props.socialUrls]);
69-
const activeAccount = useActiveAccount();
7069

7170
const cleanedChainName = props.chainMetadata?.name
7271
?.replace("Mainnet", "")
@@ -172,8 +171,7 @@ export function ContractHeaderUI(props: {
172171
variant="outline"
173172
/>
174173

175-
{props.contractCreator?.toLowerCase() ===
176-
activeAccount?.address?.toLowerCase() && (
174+
{props.isDashboardUser && (
177175
<ToolTipLabel
178176
contentClassName="max-w-[300px]"
179177
label={

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { cookies } from "next/headers";
12
import type { ThirdwebContract } from "thirdweb";
23
import type { ChainMetadata } from "thirdweb/chains";
34
import { getContractMetadata } from "thirdweb/extensions/common";
45
import { decimals, getActiveClaimCondition } from "thirdweb/extensions/erc20";
56
import { GridPattern } from "@/components/ui/background-patterns";
7+
import { HAS_USED_DASHBOARD } from "@/constants/cookie";
68
import { resolveFunctionSelectors } from "@/lib/selectors";
79
import { AssetPageView } from "../_components/asset-page-view";
810
import { getContractCreator } from "../_components/getContractCreator";
@@ -65,6 +67,9 @@ export async function ERC20PublicPage(props: {
6567
: undefined,
6668
]);
6769

70+
const cookieStore = await cookies();
71+
const isDashboardUser = cookieStore.has(HAS_USED_DASHBOARD);
72+
6873
const buyEmbed = (
6974
<BuyEmbed
7075
chainMetadata={props.chainMetadata}
@@ -96,6 +101,7 @@ export async function ERC20PublicPage(props: {
96101
clientContract={props.clientContract}
97102
contractCreator={contractCreator}
98103
image={contractMetadata.image}
104+
isDashboardUser={isDashboardUser}
99105
name={contractMetadata.name}
100106
socialUrls={
101107
typeof contractMetadata.social_urls === "object" &&

apps/dashboard/src/app/(app)/team/components/last-visited-page/SaveLastVisitedPage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { usePathname } from "next/navigation";
44
import { useEffect } from "react";
5-
import { LAST_USED_TEAM_ID } from "@/constants/cookie";
5+
import { HAS_USED_DASHBOARD, LAST_USED_TEAM_ID } from "@/constants/cookie";
66
import { setCookie } from "@/utils/cookie";
77
import { LAST_VISITED_TEAM_PAGE_PATH } from "./consts";
88

@@ -13,6 +13,7 @@ export function SaveLastVisitedTeamPage(props: { teamId: string }) {
1313
useEffect(() => {
1414
setCookie(LAST_VISITED_TEAM_PAGE_PATH, pathname);
1515
setCookie(LAST_USED_TEAM_ID, props.teamId);
16+
setCookie(HAS_USED_DASHBOARD, "true");
1617
}, [pathname, props.teamId]);
1718

1819
return null;

0 commit comments

Comments
 (0)