Skip to content

Commit 3268af6

Browse files
committed
[Dashboard] Login flow improvements (#5658)
Fixes: DASH-564 and DASH-494 <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on updating the user interface and functionality related to wallet connection across various components in the dashboard, primarily changing instances of "Sign In" to "Connect Wallet" and modifying how account information is handled. ### Detailed summary - Changed button text from `Sign In` to `Connect Wallet` in multiple components. - Updated `TeamHeader` to use `getRawAccount` instead of `getAuthToken`. - Modified account handling in `TeamLayout` functions to include `getValidAccount`. - Adjusted `LoginPage` logic for account onboarding and redirection. - Enhanced `TeamHeaderLoggedIn` to accept `account` as a prop directly. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 4ced3d2 commit 3268af6

File tree

10 files changed

+31
-27
lines changed

10 files changed

+31
-27
lines changed

apps/dashboard/src/@3rdweb-sdk/react/components/connect-wallet/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export const CustomConnectWallet = (props: {
150150
<Link
151151
href={`/login${pathname ? `?next=${encodeURIComponent(pathname)}` : ""}`}
152152
>
153-
Sign In
153+
Connect Wallet
154154
</Link>
155155
</Button>
156156
</>

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/FaucetButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export function FaucetButton({
146146
<Link
147147
href={`/login${pathname ? `?next=${encodeURIComponent(pathname)}` : ""}`}
148148
>
149-
Sign In
149+
Connect Wallet
150150
</Link>
151151
</Button>
152152
);

apps/dashboard/src/app/login/LoginPage.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,7 @@ function PageContent(props: {
123123
| {
124124
id: "complete";
125125
}
126-
>(
127-
props.account
128-
? { id: "onboarding", account: props.account }
129-
: { id: "login" },
130-
);
126+
>({ id: "login" });
131127

132128
const router = useDashboardRouter();
133129
const connectionStatus = useActiveWalletConnectionStatus();

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import { redirect } from "next/navigation";
21
import { getRawAccount } from "../account/settings/getAccount";
32
import { LoginAndOnboardingPage } from "./LoginPage";
4-
import { isOnboardingComplete } from "./onboarding/isOnboardingRequired";
53

64
export default async function Page(props: {
75
searchParams: Promise<{
@@ -11,13 +9,11 @@ export default async function Page(props: {
119
const nextPath = (await props.searchParams).next;
1210
const account = await getRawAccount();
1311

14-
if (account && isOnboardingComplete(account)) {
15-
if (nextPath) {
16-
redirect(nextPath);
17-
} else {
18-
redirect("/team");
19-
}
20-
}
12+
// don't redirect away from login page if authToken is already present and onboarding is done
13+
// so that if user is stuck in a state where cookie is set, account onboarding is complete but the wallet is not connected, they can connect wallet, sign in and continue
14+
15+
// if the user is already logged in, wallet is connected and onboarding is complete
16+
// user will be redirected to the next path on the client side without having to do anything
2117

2218
return <LoginAndOnboardingPage account={account} nextPath={nextPath} />;
2319
}

apps/dashboard/src/app/team/[team_slug]/(team)/layout.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@ import { getProjects } from "@/api/projects";
22
import { getTeamNebulaWaitList, getTeams } from "@/api/team";
33
import { TabPathLinks } from "@/components/ui/tabs";
44
import { notFound, redirect } from "next/navigation";
5+
import { getValidAccount } from "../../../account/settings/getAccount";
56
import { TeamHeaderLoggedIn } from "../../components/TeamHeader/team-header-logged-in.client";
67

78
export default async function TeamLayout(props: {
89
children: React.ReactNode;
910
params: Promise<{ team_slug: string }>;
1011
}) {
1112
const params = await props.params;
12-
const teams = await getTeams();
13+
14+
const [account, teams] = await Promise.all([
15+
getValidAccount(`/team/${params.team_slug}`),
16+
getTeams(),
17+
]);
1318

1419
if (!teams) {
1520
redirect("/login");
@@ -37,6 +42,7 @@ export default async function TeamLayout(props: {
3742
currentTeam={team}
3843
teamsAndProjects={teamsAndProjects}
3944
currentProject={undefined}
45+
account={account}
4046
/>
4147

4248
<TabPathLinks

apps/dashboard/src/app/team/[team_slug]/[project_slug]/layout.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { getProjects } from "@/api/projects";
22
import { getTeamNebulaWaitList, getTeams } from "@/api/team";
33
import { TabPathLinks } from "@/components/ui/tabs";
44
import { notFound, redirect } from "next/navigation";
5+
import { getValidAccount } from "../../../account/settings/getAccount";
56
import { TeamHeaderLoggedIn } from "../../components/TeamHeader/team-header-logged-in.client";
67

78
export default async function TeamLayout(props: {
@@ -10,7 +11,10 @@ export default async function TeamLayout(props: {
1011
params: Promise<{ team_slug: string; project_slug: string }>;
1112
}) {
1213
const params = await props.params;
13-
const teams = await getTeams();
14+
const [teams, account] = await Promise.all([
15+
getTeams(),
16+
getValidAccount(`/team/${params.team_slug}/${params.project_slug}`),
17+
]);
1418

1519
if (!teams) {
1620
redirect("/login");
@@ -49,6 +53,7 @@ export default async function TeamLayout(props: {
4953
currentProject={project}
5054
currentTeam={team}
5155
teamsAndProjects={teamsAndProjects}
56+
account={account}
5257
/>
5358
<TabPathLinks
5459
tabContainerClassName="px-4 lg:px-6"

apps/dashboard/src/app/team/components/TeamHeader/TeamHeaderLoggedOut.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function TeamHeaderLoggedOutDesktopUI(props: {
3535
<Link
3636
href={`/login${pathname ? `?next=${encodeURIComponent(pathname)}` : ""}`}
3737
>
38-
Sign in
38+
Connect Wallet
3939
</Link>
4040
</Button>
4141
</div>
@@ -64,7 +64,7 @@ export function TeamHeaderLoggedOutMobileUI(props: {
6464
<Link
6565
href={`/login${pathname ? `?next=${encodeURIComponent(pathname)}` : ""}`}
6666
>
67-
Sign in
67+
Connect Wallet
6868
</Link>
6969
</Button>
7070
<MobileBurgerMenuButton type="loggedOut" />

apps/dashboard/src/app/team/components/TeamHeader/team-header-logged-in.client.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Team } from "@/api/team";
55
import { getThirdwebClient } from "@/constants/thirdweb.server";
66
import { useDashboardRouter } from "@/lib/DashboardRouter";
77
import { CustomConnectWallet } from "@3rdweb-sdk/react/components/connect-wallet";
8-
import { useAccount } from "@3rdweb-sdk/react/hooks/useApi";
8+
import type { Account } from "@3rdweb-sdk/react/hooks/useApi";
99
import { useCallback, useState } from "react";
1010
import { useActiveWallet, useDisconnect } from "thirdweb/react";
1111
import { LazyCreateAPIKeyDialog } from "../../../../components/settings/ApiKeys/Create/LazyCreateAPIKeyDialog";
@@ -20,10 +20,10 @@ export function TeamHeaderLoggedIn(props: {
2020
currentTeam: Team;
2121
teamsAndProjects: Array<{ team: Team; projects: Project[] }>;
2222
currentProject: Project | undefined;
23+
account: Pick<Account, "email" | "id">;
2324
}) {
2425
const [isCreateProjectDialogOpen, setIsCreateProjectDialogOpen] =
2526
useState(false);
26-
const myAccountQuery = useAccount();
2727
const activeWallet = useActiveWallet();
2828
const { disconnect } = useDisconnect();
2929
const router = useDashboardRouter();
@@ -45,7 +45,7 @@ export function TeamHeaderLoggedIn(props: {
4545
currentProject: props.currentProject,
4646
currentTeam: props.currentTeam,
4747
teamsAndProjects: props.teamsAndProjects,
48-
account: myAccountQuery.data,
48+
account: props.account,
4949
logout: logout,
5050
connectButton: <CustomConnectWallet />,
5151
createProject: () => setIsCreateProjectDialogOpen(true),

apps/dashboard/src/app/team/components/TeamHeader/team-header.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { getProjects } from "@/api/projects";
22
import { getTeams } from "@/api/team";
3-
import { getAuthToken } from "../../../api/lib/getAuthToken";
3+
import { getRawAccount } from "../../../account/settings/getAccount";
44
import { TeamHeaderLoggedOut } from "./TeamHeaderLoggedOut";
55
import { TeamHeaderLoggedIn } from "./team-header-logged-in.client";
66

77
export async function TeamHeader() {
8-
const authToken = await getAuthToken();
8+
const account = await getRawAccount();
99

10-
if (!authToken) {
10+
if (!account) {
1111
return <TeamHeaderLoggedOut />;
1212
}
1313

@@ -34,6 +34,7 @@ export async function TeamHeader() {
3434
currentTeam={firstTeam}
3535
teamsAndProjects={teamsAndProjects}
3636
currentProject={undefined}
37+
account={account}
3738
/>
3839
);
3940
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export const MismatchButton = forwardRef<
108108
<Link
109109
href={`/login${pathname ? `?next=${encodeURIComponent(pathname)}` : ""}`}
110110
>
111-
Sign In
111+
Connect Wallet
112112
</Link>
113113
</Button>
114114
);

0 commit comments

Comments
 (0)