Skip to content

Commit 13a31de

Browse files
committed
Hook up onboarding to login
1 parent dbdee2b commit 13a31de

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useTheme } from "next-themes";
77
import { useSearchParams } from "next/navigation";
88
import { Suspense, useEffect, useState } from "react";
99
import { ConnectEmbed } from "thirdweb/react";
10+
import { getProfiles } from "thirdweb/wallets";
1011
import { getCookie } from "../../stores/SyncStoreToCookies";
1112
import { ThirdwebMiniLogo } from "../components/ThirdwebMiniLogo";
1213
import { getSDKTheme } from "../components/sdk-component-theme";
@@ -45,15 +46,18 @@ function CustomConnectEmmbed() {
4546
const nextSearchParam = searchParams?.get("next");
4647
const client = useThirdwebClient();
4748

48-
function onLoginSuccessful() {
49+
async function onLoginSuccessful() {
50+
const profiles = await getProfiles({ client });
4951
if (nextSearchParam && isValidRedirectPath(nextSearchParam)) {
5052
router.replace(nextSearchParam);
5153
} else {
5254
const dashboardType = getCookie("x-dashboard-type");
5355
if (dashboardType === "team") {
5456
router.replace("/team");
5557
} else {
56-
router.replace("/dashboard");
58+
router.replace(
59+
`/onboarding?${profiles[0] ? `email=${profiles[0].details.email}` : ""}`,
60+
);
5761
}
5862
}
5963
}

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

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ import {
1313
SelectValue,
1414
} from "@/components/ui/select";
1515
import { cn } from "@/lib/utils";
16+
import { useAccount } from "@3rdweb-sdk/react/hooks/useApi";
1617
import { Checkbox } from "@chakra-ui/react";
1718
import { FormControl } from "@chakra-ui/react";
1819
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
20+
import { THIRDWEB_ANALYTICS_API_HOST } from "constants/urls";
1921
import { motion } from "framer-motion";
2022
import { Users2 } from "lucide-react";
2123
import { Building } from "lucide-react";
24+
import { useRouter } from "next/navigation";
2225
import React from "react";
2326
import { useState } from "react";
2427
import {
@@ -27,10 +30,9 @@ import {
2730
type UseFormRegister,
2831
useForm,
2932
} from "react-hook-form";
33+
import { Blobbie } from "thirdweb/react";
34+
import { shortenAddress } from "thirdweb/utils";
3035
import { FormErrorMessage, FormLabel } from "tw-components";
31-
import { THIRDWEB_ANALYTICS_API_HOST } from "constants/urls";
32-
import { useAccount } from "@3rdweb-sdk/react/hooks/useApi";
33-
import { useRouter } from "next/navigation";
3436

3537
interface FormData {
3638
email: string;
@@ -65,9 +67,12 @@ const RadioGroupItemButton = React.forwardRef<
6567
);
6668
});
6769

68-
export default function OnboardingPage() {
70+
export default function OnboardingPage({
71+
searchParams,
72+
}: { searchParams: { address: string; email: string | undefined } }) {
6973
const accountQuery = useAccount();
70-
const [step, setStep] = useState(1);
74+
console.log(searchParams.email);
75+
const [step, setStep] = useState(searchParams.email ? 2 : 1);
7176
const [direction, setDirection] = useState(1);
7277
const router = useRouter();
7378

@@ -82,6 +87,7 @@ export default function OnboardingPage() {
8287
} = useForm<FormData>({
8388
defaultValues: {
8489
interests: [],
90+
email: searchParams.email ?? "",
8591
},
8692
});
8793

@@ -438,7 +444,7 @@ export default function OnboardingPage() {
438444
};
439445

440446
return (
441-
<div className="relative flex h-screen flex-col place-items-center bg-muted/30 md:flex-row">
447+
<div className="relative flex flex-col place-items-center bg-muted/30 md:flex-row">
442448
<main className="z-10 flex w-full gap-6">
443449
{/* Left Panel */}
444450
<div className="items-between relative box-border flex h-screen w-full flex-col overflow-hidden p-12 lg:w-1/2">
@@ -470,18 +476,29 @@ export default function OnboardingPage() {
470476
</div>
471477
{/* Right Panel */}
472478
<div className="flex h-screen w-1/2 animate-gradient-x flex-col items-center justify-center bg-gradient-to-r from-[#25369F] via-[#290259] to-[#3E0D45]">
473-
<Card className="flex w-[275px] items-center rounded-xl border-muted transition-all ">
479+
<Card className="flex w-[300px] items-center rounded-xl border-muted transition-all ">
474480
<CardContent className="flex items-center space-x-4 p-4">
475481
{getValues("userType") ? (
476482
getValues("userType") === "Developer" ? (
477483
<Users2 className="size-8" />
478484
) : (
479485
<Building className="size-8" />
480486
)
481-
) : null}
487+
) : (
488+
<div className="size-7 overflow-hidden rounded-full">
489+
<Blobbie
490+
address={accountQuery.data?.creatorWalletAddress ?? ""}
491+
size={28}
492+
/>
493+
</div>
494+
)}
482495
<div className="flex flex-col">
483496
<h5 className="font-regular font-sm text-white">
484-
{getValues("email") ?? "a1...b2"}
497+
{getValues("email")
498+
? getValues("email")
499+
: accountQuery.data?.creatorWalletAddress
500+
? shortenAddress(accountQuery.data?.creatorWalletAddress)
501+
: ""}
485502
</h5>
486503

487504
<h5

0 commit comments

Comments
 (0)