@@ -41,6 +41,7 @@ const profileSchema = z.object({
4141 currentPassword : z . string ( ) . nullable ( ) ,
4242 image : z . string ( ) . optional ( ) ,
4343 name : z . string ( ) . optional ( ) ,
44+ lastName : z . string ( ) . optional ( ) ,
4445 allowImpersonation : z . boolean ( ) . optional ( ) . default ( false ) ,
4546} ) ;
4647
@@ -88,7 +89,8 @@ export const ProfileForm = () => {
8889 image : data ?. user ?. image || "" ,
8990 currentPassword : "" ,
9091 allowImpersonation : data ?. user ?. allowImpersonation || false ,
91- name : data ?. user ?. name || "" ,
92+ name : data ?. user ?. firstName || "" ,
93+ lastName : data ?. user ?. lastName || "" ,
9294 } ,
9395 resolver : zodResolver ( profileSchema ) ,
9496 } ) ;
@@ -102,7 +104,8 @@ export const ProfileForm = () => {
102104 image : data ?. user ?. image || "" ,
103105 currentPassword : form . getValues ( "currentPassword" ) || "" ,
104106 allowImpersonation : data ?. user ?. allowImpersonation ,
105- name : data ?. user ?. name || "" ,
107+ name : data ?. user ?. firstName || "" ,
108+ lastName : data ?. user ?. lastName || "" ,
106109 } ,
107110 {
108111 keepValues : true ,
@@ -127,6 +130,7 @@ export const ProfileForm = () => {
127130 currentPassword : values . currentPassword || undefined ,
128131 allowImpersonation : values . allowImpersonation ,
129132 name : values . name || undefined ,
133+ lastName : values . lastName || undefined ,
130134 } ) ;
131135 await refetch ( ) ;
132136 toast . success ( "Profile Updated" ) ;
@@ -136,6 +140,7 @@ export const ProfileForm = () => {
136140 image : values . image ,
137141 currentPassword : "" ,
138142 name : values . name || "" ,
143+ lastName : values . lastName || "" ,
139144 } ) ;
140145 } catch ( error ) {
141146 toast . error ( "Error updating the profile" ) ;
@@ -180,9 +185,22 @@ export const ProfileForm = () => {
180185 name = "name"
181186 render = { ( { field } ) => (
182187 < FormItem >
183- < FormLabel > Name</ FormLabel >
188+ < FormLabel > First Name</ FormLabel >
184189 < FormControl >
185- < Input placeholder = "Name" { ...field } />
190+ < Input placeholder = "John" { ...field } />
191+ </ FormControl >
192+ < FormMessage />
193+ </ FormItem >
194+ ) }
195+ />
196+ < FormField
197+ control = { form . control }
198+ name = "lastName"
199+ render = { ( { field } ) => (
200+ < FormItem >
201+ < FormLabel > Last Name</ FormLabel >
202+ < FormControl >
203+ < Input placeholder = "Doe" { ...field } />
186204 </ FormControl >
187205 < FormMessage />
188206 </ FormItem >
@@ -280,7 +298,7 @@ export const ProfileForm = () => {
280298 < Avatar className = "default-avatar h-12 w-12 rounded-full border hover:p-px hover:border-primary transition-transform" >
281299 < AvatarFallback className = "rounded-lg" >
282300 { getFallbackAvatarInitials (
283- data ?. user ?. name ,
301+ ` ${ data ?. user ?. firstName } ${ data ?. user ?. lastName } ` . trim ( ) ,
284302 ) }
285303 </ AvatarFallback >
286304 </ Avatar >
0 commit comments