@@ -11,7 +11,7 @@ import { useAuth } from "@/lib/auth";
1111
1212export default function InvitationSetup ( ) {
1313 const navigate = useNavigate ( ) ;
14- const [ name , setName ] = useState ( "" ) ;
14+ const [ username , setUsername ] = useState ( "" ) ;
1515 const [ password , setPassword ] = useState ( "" ) ;
1616 const [ confirmPassword , setConfirmPassword ] = useState ( "" ) ;
1717 const [ isLoading , setIsLoading ] = useState ( false ) ;
@@ -99,8 +99,8 @@ export default function InvitationSetup() {
9999 setUserEmail ( currentUser . email || '' ) ;
100100
101101 // Check if user already completed setup directly from the session
102- if ( currentUser . user_metadata ?. name || currentUser . user_metadata ?. full_name ) {
103- console . log ( 'User already has name in metadata, redirecting to dashboard' ) ;
102+ if ( currentUser . user_metadata ?. username || currentUser . user_metadata ?. name || currentUser . user_metadata ?. full_name ) {
103+ console . log ( 'User already has username in metadata, redirecting to dashboard' ) ;
104104 navigate ( '/dashboard' ) ;
105105 return ;
106106 }
@@ -109,11 +109,11 @@ export default function InvitationSetup() {
109109 try {
110110 const { data : profile , error : profileError } = await supabase
111111 . from ( 'profiles' )
112- . select ( 'name, full_name ' )
112+ . select ( 'name' )
113113 . eq ( 'id' , currentUser . id )
114114 . single ( ) ;
115115
116- if ( ! profileError && profile && ( profile . name || profile . full_name ) ) {
116+ if ( ! profileError && profile && profile . name ) {
117117 console . log ( 'User already has profile, redirecting to dashboard' ) ;
118118 navigate ( '/dashboard' ) ;
119119 return ;
@@ -161,8 +161,10 @@ export default function InvitationSetup() {
161161 setError ( "" ) ;
162162
163163 // Validation
164- if ( ! name . trim ( ) ) {
165- setError ( "Please enter your name" ) ;
164+ const trimmedUsername = username . trim ( ) ;
165+
166+ if ( ! trimmedUsername ) {
167+ setError ( "Please enter your username" ) ;
166168 return ;
167169 }
168170
@@ -183,8 +185,8 @@ export default function InvitationSetup() {
183185 const { error : updateError } = await supabase . auth . updateUser ( {
184186 password : password ,
185187 data : {
186- name : name . trim ( ) ,
187- full_name : name . trim ( )
188+ name : trimmedUsername ,
189+ username : trimmedUsername
188190 }
189191 } ) ;
190192
@@ -204,8 +206,7 @@ export default function InvitationSetup() {
204206 . upsert ( {
205207 id : user . id ,
206208 email : user . email ,
207- name : name . trim ( ) ,
208- full_name : name . trim ( ) ,
209+ name : trimmedUsername ,
209210 updated_at : new Date ( ) . toISOString ( )
210211 } ) ;
211212
@@ -313,7 +314,7 @@ export default function InvitationSetup() {
313314 < CardHeader >
314315 < CardTitle > Complete Your Account Setup</ CardTitle >
315316 < CardDescription >
316- Welcome! Please set your name and password to complete your account.
317+ Welcome! Please set your username and password to complete your account.
317318 </ CardDescription >
318319 </ CardHeader >
319320 < form onSubmit = { handleSubmit } >
@@ -334,14 +335,14 @@ export default function InvitationSetup() {
334335 ) }
335336
336337 < div className = "space-y-2" >
337- < Label htmlFor = "name" > Your Name </ Label >
338+ < Label htmlFor = "username" > Username </ Label >
338339 < div className = "relative" >
339340 < Input
340- id = "name "
341+ id = "username "
341342 type = "text"
342- placeholder = "Enter your full name "
343- value = { name }
344- onChange = { ( e ) => setName ( e . target . value ) }
343+ placeholder = "Pick a username "
344+ value = { username }
345+ onChange = { ( e ) => setUsername ( e . target . value ) }
345346 required
346347 disabled = { isLoading }
347348 />
@@ -422,7 +423,7 @@ export default function InvitationSetup() {
422423 < Button
423424 type = "submit"
424425 className = "w-full"
425- disabled = { isLoading || ! name || ! password || ! confirmPassword }
426+ disabled = { isLoading || ! username || ! password || ! confirmPassword }
426427 >
427428 { isLoading ? (
428429 < >
@@ -441,4 +442,4 @@ export default function InvitationSetup() {
441442 </ Card >
442443 </ div >
443444 ) ;
444- }
445+ }
0 commit comments