@@ -14,7 +14,7 @@ export function RefcodeCreator ({
14
14
urlQueryEmail,
15
15
createRefcode,
16
16
mutateRefcode,
17
- setReferrerEmail,
17
+ setReferrerEmail
18
18
} : {
19
19
accountEmail : string
20
20
urlQueryEmail : string | null
@@ -43,10 +43,16 @@ export function RefcodeCreator ({
43
43
< form onSubmit = { async ( e ) => {
44
44
e . preventDefault ( )
45
45
try {
46
- console . log ( "CREATING REFCODE" )
47
- await createRefcode ( new FormData ( e . currentTarget ) )
46
+ const form = new FormData ( e . currentTarget )
47
+ const email = form . get ( 'email' )
48
+ if ( email ) {
49
+ setReferrerEmail ( email . toString ( ) )
50
+ await createRefcode ( form )
51
+ } else {
52
+ console . log ( "email was undefined, this is strange!" )
53
+ }
48
54
} finally {
49
- console . log ( "MUTATING REFCODE" )
55
+ // mutate here to pick up any changes from either create or set
50
56
mutateRefcode ( )
51
57
}
52
58
} } className = '' >
@@ -57,13 +63,8 @@ export function RefcodeCreator ({
57
63
type = 'email'
58
64
className = 'text-black py-2 px-2 rounded-xl block mb-4 border border-hot-red w-80'
59
65
placeholder = 'Email'
66
+ defaultValue = { urlQueryEmail || '' }
60
67
required = { true }
61
- defaultValue = { urlQueryEmail || "" }
62
- onChange = { async ( e ) => {
63
- setReferrerEmail ( e . target . value ) ;
64
- console . log ( "MUTATING REFCODE" , e . target . value )
65
- await mutateRefcode ( )
66
- } }
67
68
/>
68
69
< button type = 'submit' className = { `inline-block bg-hot-red border border-hot-red hover:bg-white hover:text-hot-red font-epilogue text-white uppercase text-sm px-6 py-2 rounded-full whitespace-nowrap` } >
69
70
Create
@@ -119,10 +120,10 @@ export function ReferralsList () {
119
120
}
120
121
121
122
export default function ReferralsPage ( ) {
122
- const { refcodeIsLoading, referralLink, referrerEmail , setReferrerEmail, accountEmail, urlQueryEmail, createRefcode, mutateRefcode, } = useReferrals ( )
123
+ const { refcodeIsLoading, referralLink, setReferrerEmail, accountEmail, urlQueryEmail, createRefcode, mutateRefcode, } = useReferrals ( )
123
124
return (
124
125
< div className = 'p-10 bg-racha-fire/50 w-full h-screen' >
125
- < H1 > Generate a Referral Code { referrerEmail } </ H1 >
126
+ < H1 > Generate a Referral Code</ H1 >
126
127
< div className = 'border border-hot-red rounded-2xl bg-white p-5' >
127
128
{ refcodeIsLoading ? (
128
129
< DefaultLoader className = "text-hot-red h-6 w-6" />
0 commit comments