File tree Expand file tree Collapse file tree 2 files changed +30
-4
lines changed
apps/web/app/partners.dub.co/(onboarding)/onboarding Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import { onboardPartnerAction } from "@/lib/actions/partners/onboard-partner" ;
4
4
import { onboardPartnerSchema } from "@/lib/zod/schemas/partners" ;
5
+ import { Partner } from "@dub/prisma/client" ;
5
6
import {
6
7
Button ,
7
8
buttonVariants ,
@@ -21,7 +22,11 @@ import ReactTextareaAutosize from "react-textarea-autosize";
21
22
import { toast } from "sonner" ;
22
23
import { z } from "zod" ;
23
24
24
- export function OnboardingForm ( ) {
25
+ export function OnboardingForm ( {
26
+ partner,
27
+ } : {
28
+ partner : Pick < Partner , "bio" | "country" | "image" > | null ;
29
+ } ) {
25
30
const router = useRouter ( ) ;
26
31
const { data : session } = useSession ( ) ;
27
32
const { isMobile } = useMediaQuery ( ) ;
@@ -34,7 +39,13 @@ export function OnboardingForm() {
34
39
setValue,
35
40
watch,
36
41
formState : { errors, isSubmitting, isSubmitSuccessful } ,
37
- } = useForm < z . infer < typeof onboardPartnerSchema > > ( ) ;
42
+ } = useForm < z . infer < typeof onboardPartnerSchema > > ( {
43
+ defaultValues : {
44
+ description : partner ?. bio ?? undefined ,
45
+ country : partner ?. country ?? undefined ,
46
+ image : partner ?. image ?? undefined ,
47
+ } ,
48
+ } ) ;
38
49
39
50
useEffect ( ( ) => {
40
51
if ( session ?. user ) {
Original file line number Diff line number Diff line change
1
+ import { getSession } from "@/lib/auth" ;
2
+ import { prisma } from "@dub/prisma" ;
1
3
import { ConnectedDots4 } from "@dub/ui/icons" ;
2
4
import { OnboardingForm } from "./onboarding-form" ;
3
5
4
- export default function Onboarding ( ) {
6
+ export default async function Onboarding ( ) {
7
+ const { user } = await getSession ( ) ;
8
+
9
+ const partner = await prisma . partner . findUnique ( {
10
+ where : {
11
+ email : user . email ,
12
+ } ,
13
+ select : {
14
+ bio : true ,
15
+ country : true ,
16
+ image : true ,
17
+ } ,
18
+ } ) ;
19
+
5
20
return (
6
21
< div className = "mx-auto my-10 flex w-full max-w-sm flex-col items-center md:mt-14" >
7
22
< div className = "animate-slide-up-fade flex size-10 items-center justify-center rounded-full border border-neutral-200 bg-white backdrop-blur-sm [--offset:8px] [animation-delay:250ms] [animation-duration:1s] [animation-fill-mode:both]" >
@@ -11,7 +26,7 @@ export default function Onboarding() {
11
26
Create your Dub Partner profile
12
27
</ h1 >
13
28
< div className = "animate-slide-up-fade mt-8 w-full [--offset:10px] [animation-delay:500ms] [animation-duration:1s] [animation-fill-mode:both]" >
14
- < OnboardingForm />
29
+ < OnboardingForm partner = { partner } />
15
30
</ div >
16
31
</ div >
17
32
) ;
You can’t perform that action at this time.
0 commit comments