Skip to content

Commit 6e6d907

Browse files
committed
[Dashboard] Onboarding UI adjustments + use doLogout server action instead of fetch (#5480)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR primarily focuses on refactoring the logout functionality across various components by replacing direct API calls with a centralized `doLogout` function. It also includes some UI adjustments and enhancements. ### Detailed summary - Removed direct API call to `/api/auth/logout` in favor of `doLogout()` in multiple components. - Updated styles for various UI elements, including `AccountForm` and `OnboardingChoosePlan`. - Adjusted layout and class names for better responsiveness and appearance. - Added `Aurora` component for visual effects in the `LoginAndOnboardingPage`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent e9ea476 commit 6e6d907

File tree

10 files changed

+77
-67
lines changed

10 files changed

+77
-67
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
useConnectModal,
2222
} from "thirdweb/react";
2323
import { useFavoriteChainIds } from "../../../../app/(dashboard)/(chain)/components/client/star-button";
24+
import { doLogout } from "../../../../app/login/auth-actions";
2425
import { LazyConfigureNetworkModal } from "../../../../components/configure-networks/LazyConfigureNetworkModal";
2526
import { useAllChainsData } from "../../../../hooks/chains/allChains";
2627
import {
@@ -174,10 +175,7 @@ export const CustomConnectWallet = (props: {
174175
}}
175176
onDisconnect={async () => {
176177
try {
177-
// log out the user
178-
await fetch("/api/auth/logout", {
179-
method: "POST",
180-
});
178+
await doLogout();
181179
} catch (err) {
182180
console.error("Failed to log out", err);
183181
}

apps/dashboard/src/app/account/components/AccountHeader.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useAccount } 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";
12+
import { doLogout } from "../../login/auth-actions";
1213
import {
1314
type AccountHeaderCompProps,
1415
AccountHeaderDesktopUI,
@@ -27,11 +28,8 @@ export function AccountHeader(props: {
2728
const { disconnect } = useDisconnect();
2829

2930
const logout = useCallback(async () => {
30-
// log out the user
3131
try {
32-
await fetch("/api/auth/logout", {
33-
method: "POST",
34-
});
32+
await doLogout();
3533
if (wallet) {
3634
disconnect(wallet);
3735
}

apps/dashboard/src/app/api/auth/logout/route.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

apps/dashboard/src/app/components/Header/SecondaryNav/SecondaryNav.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export function SecondaryNavLinks() {
3939
<Link
4040
href="https://portal.thirdweb.com/"
4141
className="text-muted-foreground text-sm hover:text-foreground"
42+
target="_blank"
4243
>
4344
Docs
4445
</Link>

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

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useThirdwebClient } from "@/constants/thirdweb.client";
77
import { useDashboardRouter } from "@/lib/DashboardRouter";
88
import type { Account } from "@3rdweb-sdk/react/hooks/useApi";
99
import { useTheme } from "next-themes";
10+
import Link from "next/link";
1011
import { Suspense, lazy, useState } from "react";
1112
import { ConnectEmbed, useActiveWalletConnectionStatus } from "thirdweb/react";
1213
import { createWallet, inAppWallet } from "thirdweb/wallets";
@@ -46,20 +47,39 @@ export function LoginAndOnboardingPage(props: {
4647
nextPath: string | undefined;
4748
}) {
4849
return (
49-
<div className="flex min-h-screen flex-col bg-background">
50+
<div className="relative flex min-h-screen flex-col overflow-hidden bg-background">
5051
<div className="border-b bg-background">
5152
<header className="container flex w-full flex-row items-center justify-between px-6 py-4">
5253
<div className="flex shrink-0 items-center gap-3">
5354
<ThirdwebMiniLogo className="size-7 md:size-8" />
5455
<h1 className="font-medium text-lg tracking-tight md:text-xl">
55-
Get started with thirdweb
56+
Get started <span className="max-sm:hidden">with thirdweb</span>
5657
</h1>
5758
</div>
58-
<ColorModeToggle />
59+
60+
<div className="flex items-center gap-3">
61+
<Link
62+
href="/support"
63+
target="_blank"
64+
className="px-2 text-muted-foreground text-sm hover:text-foreground"
65+
>
66+
Support
67+
</Link>
68+
69+
<Link
70+
href="https://portal.thirdweb.com/"
71+
className="px-2 text-muted-foreground text-sm hover:text-foreground"
72+
target="_blank"
73+
>
74+
Docs
75+
</Link>
76+
77+
<ColorModeToggle />
78+
</div>
5979
</header>
6080
</div>
6181

62-
<main className="z-10 flex grow flex-col items-center justify-center gap-6 py-12">
82+
<main className="container z-10 flex grow flex-col items-center justify-center gap-6 py-12">
6383
<ClientOnly ssr={<LoadingCard />}>
6484
<PageContent nextPath={props.nextPath} account={props.account} />
6585
</ClientOnly>
@@ -69,15 +89,21 @@ export function LoginAndOnboardingPage(props: {
6989
<img
7090
alt=""
7191
src="/assets/login/background.svg"
72-
className="-bottom-12 -right-12 fixed lg:right-0 lg:bottom-0"
92+
className="-bottom-12 -right-12 pointer-events-none fixed lg:right-0 lg:bottom-0"
93+
/>
94+
95+
<Aurora
96+
color="hsl(var(--foreground)/9%)"
97+
pos={{ top: "55%", left: "50%" }}
98+
size={{ width: "1400px", height: "1300px" }}
7399
/>
74100
</div>
75101
);
76102
}
77103

78104
function LoadingCard() {
79105
return (
80-
<div className="flex min-h-[450px] w-[calc(100vw-60px)] max-w-[500px] items-center justify-center rounded-lg border border-border bg-background">
106+
<div className="flex min-h-[450px] w-full items-center justify-center rounded-xl border border-border bg-background shadow-lg lg:w-[500px]">
81107
<Spinner className="size-10" />
82108
</div>
83109
);
@@ -202,3 +228,25 @@ function isValidRedirectPath(encodedPath: string): boolean {
202228
return false;
203229
}
204230
}
231+
232+
type AuroraProps = {
233+
size: { width: string; height: string };
234+
pos: { top: string; left: string };
235+
color: string;
236+
};
237+
238+
const Aurora: React.FC<AuroraProps> = ({ color, pos, size }) => {
239+
return (
240+
<div
241+
className="pointer-events-none absolute"
242+
style={{
243+
top: pos.top,
244+
left: pos.left,
245+
width: size.width,
246+
height: size.height,
247+
transform: "translate(-50%, -50%)",
248+
backgroundImage: `radial-gradient(ellipse at center, ${color}, transparent 60%)`,
249+
}}
250+
/>
251+
);
252+
};

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useAccount } 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";
12+
import { doLogout } from "../../../login/auth-actions";
1213
import {
1314
type TeamHeaderCompProps,
1415
TeamHeaderDesktopUI,
@@ -30,9 +31,7 @@ export function TeamHeaderLoggedIn(props: {
3031
const logout = useCallback(async () => {
3132
// log out the user
3233
try {
33-
await fetch("/api/auth/logout", {
34-
method: "POST",
35-
});
34+
await doLogout();
3635
if (activeWallet) {
3736
disconnect(activeWallet);
3837
}

apps/dashboard/src/components/onboarding/ChoosePlan.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ export function OnboardingChoosePlan(props: {
1212
return (
1313
<div>
1414
<TitleAndDescription
15-
heading="Choose your plan"
16-
description="Get started for free with our Starter plan or subscribe to Growth plan to unlock higher rate limits and advanced features."
15+
heading="Choose your Plan"
16+
description="Get started for free with our Starter plan or subscribe to Growth plan to unlock higher rate limits and advanced features"
1717
/>
1818

1919
<div className="h-4" />
2020

21-
<div className="grid grid-cols-1 gap-8 md:grid-cols-2 md:gap-4">
21+
<div className="grid grid-cols-1 gap-6 md:grid-cols-2 md:gap-4">
2222
<PricingCard
2323
billingPlan="starter"
2424
teamSlug={props.teamSlug}
@@ -43,14 +43,15 @@ export function OnboardingChoosePlan(props: {
4343
variant: "default",
4444
}}
4545
canTrialGrowth={props.canTrialGrowth}
46+
highlighted
4647
/>
4748
</div>
4849

49-
<div className="h-3" />
50+
<div className="h-4" />
5051

51-
<div className="flex justify-end">
52+
<div className="flex justify-center">
5253
<Button
53-
variant="ghost"
54+
variant="link"
5455
onClick={props.skipPlan}
5556
className="inline-flex translate-x-2 items-center gap-2 text-muted-foreground"
5657
>

apps/dashboard/src/components/onboarding/General.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useMutation } from "@tanstack/react-query";
55
import { AccountForm } from "components/settings/Account/AccountForm";
66
import { useState } from "react";
77
import { useActiveWallet, useDisconnect } from "thirdweb/react";
8+
import { doLogout } from "../../app/login/auth-actions";
89
import { TitleAndDescription } from "./Title";
910

1011
type OnboardingGeneralProps = {
@@ -23,17 +24,10 @@ export const OnboardingGeneral: React.FC<OnboardingGeneralProps> = ({
2324
const { disconnect } = useDisconnect();
2425

2526
async function handleLogout() {
26-
await fetch("/api/auth/logout", {
27-
method: "POST",
28-
})
29-
.catch((err) => {
30-
console.error("Failed to log out", err);
31-
})
32-
.then(() => {
33-
if (activeWallet) {
34-
disconnect(activeWallet);
35-
}
36-
});
27+
await doLogout();
28+
if (activeWallet) {
29+
disconnect(activeWallet);
30+
}
3731
}
3832

3933
const logoutMutation = useMutation({
@@ -60,7 +54,6 @@ export const OnboardingGeneral: React.FC<OnboardingGeneralProps> = ({
6054
account={account}
6155
buttonText={!existing ? "Get Started for Free" : "Login"}
6256
trackingCategory="onboarding"
63-
padded={false}
6457
onSave={onSave}
6558
onDuplicateError={onDuplicate}
6659
/>

apps/dashboard/src/components/onboarding/on-boarding-ui.client.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ function OnboardingUI(props: {
5050
return (
5151
<div
5252
className={cn(
53-
"relative w-screen rounded-lg border border-border bg-background p-4 lg:p-6",
54-
screen.id === "plan" ? "max-w-[750px]" : "max-w-[500px]",
53+
"relative w-full rounded-xl border border-border bg-background p-6 shadow-lg",
54+
screen.id === "plan" ? "lg:max-w-[750px]" : "lg:w-[500px]",
5555
)}
5656
>
5757
{screen.id === "onboarding" && (

apps/dashboard/src/components/settings/Account/AccountForm.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Spinner } from "@/components/ui/Spinner/Spinner";
33
import { Button } from "@/components/ui/button";
44
import { Checkbox, CheckboxWithLabel } from "@/components/ui/checkbox";
55
import { Input } from "@/components/ui/input";
6-
import { cn } from "@/lib/utils";
76
import { type Account, useUpdateAccount } from "@3rdweb-sdk/react/hooks/useApi";
87
import { zodResolver } from "@hookform/resolvers/zod";
98
import { useTrack } from "hooks/analytics/useTrack";
@@ -32,11 +31,9 @@ export const AccountForm: React.FC<AccountFormProps> = ({
3231
onSave,
3332
onDuplicateError,
3433
buttonText = "Save",
35-
horizontal = false,
3634
hideName = false,
3735
showSubscription = false,
3836
disableUnchanged = false,
39-
padded = true,
4037
}) => {
4138
const [isSubscribing, setIsSubscribing] = useState(true);
4239
const trackEvent = useTrack();
@@ -106,16 +103,8 @@ export const AccountForm: React.FC<AccountFormProps> = ({
106103

107104
return (
108105
<form onSubmit={handleSubmit}>
109-
<div
110-
className={cn(
111-
"flex w-full flex-col items-start rounded-xl bg-background",
112-
horizontal ? "gap-6" : "gap-8",
113-
padded ? "border border-border p-6" : "p-0",
114-
)}
115-
>
116-
<div
117-
className={cn("flex w-full", horizontal ? "gap-4" : "flex-col gap-4")}
118-
>
106+
<div className="flex w-full flex-col items-start gap-8 rounded-xl">
107+
<div className="flex w-full flex-col gap-4">
119108
<FormFieldSetup
120109
isRequired
121110
htmlFor="email"

0 commit comments

Comments
 (0)