@@ -30,13 +30,15 @@ interface EditProfileDialogProps {
3030 name ?: string ;
3131 description ?: string ;
3232 githubLogin ?: string ;
33+ twitterHandle ?: string ;
3334 children : React . ReactNode ;
3435}
3536
3637const formSchema = z . object ( {
3738 name : z . string ( ) . min ( 2 , { message : "Name must be at least 2 characters." } ) ,
3839 description : z . string ( ) . optional ( ) ,
3940 githubLogin : z . string ( ) . optional ( ) ,
41+ twitterHandle : z . string ( ) . optional ( ) ,
4042} ) ;
4143
4244type FormValues = z . infer < typeof formSchema > ;
@@ -46,6 +48,7 @@ export function EditProfileDialog({
4648 name,
4749 description,
4850 githubLogin,
51+ twitterHandle,
4952 children,
5053} : EditProfileDialogProps ) {
5154 const [ open , setOpen ] = useState ( false ) ;
@@ -58,6 +61,7 @@ export function EditProfileDialog({
5861 name : name || "" ,
5962 description : description || "" ,
6063 githubLogin : githubLogin || "" ,
64+ twitterHandle : twitterHandle || "" ,
6165 } ,
6266 } ) ;
6367
@@ -67,9 +71,10 @@ export function EditProfileDialog({
6771 name : name || "" ,
6872 description : description || "" ,
6973 githubLogin : githubLogin || "" ,
74+ twitterHandle : twitterHandle || "" ,
7075 } ) ;
7176 }
72- } , [ open , name , description , githubLogin , form ] ) ;
77+ } , [ open , name , description , githubLogin , twitterHandle , form ] ) ;
7378
7479 const onSubmit = async ( values : FormValues ) => {
7580 try {
@@ -78,6 +83,7 @@ export function EditProfileDialog({
7883 name : values . name ,
7984 description : values . description || "" ,
8085 github_login : values . githubLogin || "" ,
86+ twitter_handle : values . twitterHandle || "" ,
8187 } ,
8288 } ) ;
8389 await queryClient . invalidateQueries ( { queryKey : [ "profiles" ] } ) ;
@@ -145,6 +151,22 @@ export function EditProfileDialog({
145151 </ FormItem >
146152 ) }
147153 />
154+ < FormField
155+ control = { form . control }
156+ name = "twitterHandle"
157+ render = { ( { field } ) => (
158+ < FormItem >
159+ < FormLabel > Twitter/X Handle</ FormLabel >
160+ < FormControl >
161+ < div className = "flex items-center gap-2" >
162+ < span className = "text-sm text-gray-500" > @</ span >
163+ < Input placeholder = "username" { ...field } />
164+ </ div >
165+ </ FormControl >
166+ < FormMessage />
167+ </ FormItem >
168+ ) }
169+ />
148170 < div className = "flex justify-end gap-2 pt-2" >
149171 < DialogClose asChild >
150172 < Button type = "button" variant = "secondary" >
0 commit comments