1
+ import { Avatar , AvatarFallback , AvatarImage } from '@/components/primitives/avatar' ;
2
+ import { Tooltip , TooltipContent , TooltipTrigger } from '@/components/primitives/tooltip' ;
1
3
import { useCreateSubscriber } from '@/hooks/use-create-subscriber' ;
4
+ import { useTelemetry } from '@/hooks/use-telemetry' ;
5
+ import { TelemetryEvent } from '@/utils/telemetry' ;
2
6
import { zodResolver } from '@hookform/resolvers/zod' ;
3
7
import { loadLanguage } from '@uiw/codemirror-extensions-langs' ;
4
8
import { useForm } from 'react-hook-form' ;
@@ -19,8 +23,6 @@ import TruncatedText from '../truncated-text';
19
23
import { LocaleSelect } from './locale-select' ;
20
24
import { CreateSubscriberFormSchema } from './schema' ;
21
25
import { TimezoneSelect } from './timezone-select' ;
22
- import { useTelemetry } from '@/hooks/use-telemetry' ;
23
- import { TelemetryEvent } from '@/utils/telemetry' ;
24
26
25
27
const extensions = [ loadLanguage ( 'json' ) ?. extension ?? [ ] ] ;
26
28
const basicSetup = { lineNumbers : true , defaultKeymap : true } ;
@@ -86,6 +88,9 @@ export const CreateSubscriberForm = (props: CreateSubscriberFormProps) => {
86
88
} ) ;
87
89
} ;
88
90
91
+ const firstNameChar = form . getValues ( 'firstName' ) ?. charAt ( 0 ) || '' ;
92
+ const lastNameChar = form . getValues ( 'lastName' ) ?. charAt ( 0 ) || '' ;
93
+
89
94
return (
90
95
< div className = "flex h-full flex-col" >
91
96
< header className = "border-bg-soft flex h-12 w-full flex-row items-center gap-3 border-b p-3.5" >
@@ -97,49 +102,74 @@ export const CreateSubscriberForm = (props: CreateSubscriberFormProps) => {
97
102
< Form { ...form } >
98
103
< FormRoot autoComplete = "off" noValidate onSubmit = { form . handleSubmit ( onSubmit ) } className = "flex h-full flex-col" >
99
104
< div className = "flex flex-col items-stretch gap-6 p-5" >
100
- < div className = "grid grid-cols-2 gap-2.5" >
101
- < FormField
102
- control = { form . control }
103
- name = "firstName"
104
- render = { ( { field, fieldState } ) => (
105
- < FormItem >
106
- < FormLabel > First Name</ FormLabel >
107
- < FormControl >
108
- < Input
109
- { ...field }
110
- placeholder = { field . name }
111
- id = { field . name }
112
- value = { field . value }
113
- onChange = { field . onChange }
114
- hasError = { ! ! fieldState . error }
115
- size = "xs"
116
- />
117
- </ FormControl >
118
- < FormMessage />
119
- </ FormItem >
120
- ) }
121
- />
122
- < FormField
123
- control = { form . control }
124
- name = "lastName"
125
- render = { ( { field, fieldState } ) => (
126
- < FormItem >
127
- < FormLabel > Last Name</ FormLabel >
128
- < FormControl >
129
- < Input
130
- { ...field }
131
- placeholder = { field . name }
132
- id = { field . name }
133
- value = { field . value }
134
- onChange = { field . onChange }
135
- hasError = { ! ! fieldState . error }
136
- size = "xs"
137
- />
138
- </ FormControl >
139
- < FormMessage />
140
- </ FormItem >
141
- ) }
142
- />
105
+ < div className = "flex items-center gap-3" >
106
+ < Tooltip >
107
+ < TooltipTrigger
108
+ type = "button"
109
+ onClick = { ( e ) => {
110
+ e . preventDefault ( ) ;
111
+ e . stopPropagation ( ) ;
112
+ } }
113
+ >
114
+ < Avatar className = "size-[3.75rem] cursor-default" >
115
+ < AvatarImage src = { firstNameChar || lastNameChar ? '' : '/images/avatar.svg' } />
116
+ < AvatarFallback >
117
+ { firstNameChar || lastNameChar ? (
118
+ firstNameChar + lastNameChar
119
+ ) : (
120
+ < AvatarImage src = "/images/avatar.svg" />
121
+ ) }
122
+ </ AvatarFallback >
123
+ </ Avatar >
124
+ </ TooltipTrigger >
125
+ < TooltipContent className = "max-w-56" >
126
+ Subscriber profile Image can only be updated via API
127
+ </ TooltipContent >
128
+ </ Tooltip >
129
+ < div className = "grid w-full grid-cols-2 gap-2.5" >
130
+ < FormField
131
+ control = { form . control }
132
+ name = "firstName"
133
+ render = { ( { field, fieldState } ) => (
134
+ < FormItem >
135
+ < FormLabel > First Name</ FormLabel >
136
+ < FormControl >
137
+ < Input
138
+ { ...field }
139
+ placeholder = { 'John' }
140
+ id = { field . name }
141
+ value = { field . value }
142
+ onChange = { field . onChange }
143
+ hasError = { ! ! fieldState . error }
144
+ size = "xs"
145
+ />
146
+ </ FormControl >
147
+ < FormMessage />
148
+ </ FormItem >
149
+ ) }
150
+ />
151
+ < FormField
152
+ control = { form . control }
153
+ name = "lastName"
154
+ render = { ( { field, fieldState } ) => (
155
+ < FormItem >
156
+ < FormLabel > Last Name</ FormLabel >
157
+ < FormControl >
158
+ < Input
159
+ { ...field }
160
+ placeholder = { 'Doe' }
161
+ id = { field . name }
162
+ value = { field . value }
163
+ onChange = { field . onChange }
164
+ hasError = { ! ! fieldState . error }
165
+ size = "xs"
166
+ />
167
+ </ FormControl >
168
+ < FormMessage />
169
+ </ FormItem >
170
+ ) }
171
+ />
172
+ </ div >
143
173
</ div >
144
174
< div >
145
175
< FormField
@@ -238,12 +268,12 @@ export const CreateSubscriberForm = (props: CreateSubscriberFormProps) => {
238
268
/>
239
269
</ div >
240
270
241
- < div className = "flex flex-nowrap gap-2.5" >
271
+ < div className = "grid grid-cols-[1fr_3fr] gap-2.5" >
242
272
< FormField
243
273
control = { form . control }
244
274
name = "locale"
245
275
render = { ( { field } ) => (
246
- < FormItem className = "w-1/4" >
276
+ < FormItem >
247
277
< FormLabel > Locale</ FormLabel >
248
278
< FormControl >
249
279
< LocaleSelect
@@ -262,7 +292,7 @@ export const CreateSubscriberForm = (props: CreateSubscriberFormProps) => {
262
292
control = { form . control }
263
293
name = "timezone"
264
294
render = { ( { field } ) => (
265
- < FormItem className = "flex-1 " >
295
+ < FormItem className = "overflow-hidden " >
266
296
< FormLabel > Timezone</ FormLabel >
267
297
< FormControl >
268
298
< TimezoneSelect
0 commit comments