11import type { ILivechatContact , Serialized } from '@rocket.chat/core-typings' ;
2- import { Field , FieldLabel , FieldRow , FieldError , TextInput , ButtonGroup , Button , IconButton , Divider } from '@rocket.chat/fuselage' ;
2+ import { ButtonGroup , Button , IconButton , Divider } from '@rocket.chat/fuselage' ;
3+ import { Field , FieldLabel , FieldRow , FieldError , TextInput } from '@rocket.chat/fuselage-forms' ;
34import { validateEmail } from '@rocket.chat/tools' ;
45import {
56 CustomFieldsForm ,
@@ -192,9 +193,6 @@ const EditContactInfo = ({ contactData, onClose, onCancel }: ContactNewEditProps
192193 ) ;
193194
194195 const formId = useId ( ) ;
195- const nameField = useId ( ) ;
196- const emailField = useId ( ) ;
197- const phoneField = useId ( ) ;
198196
199197 if ( isLoadingCustomFields ) {
200198 return < ContextualbarSkeleton onClose = { onClose } /> ;
@@ -209,33 +207,19 @@ const EditContactInfo = ({ contactData, onClose, onCancel }: ContactNewEditProps
209207 </ ContextualbarHeader >
210208 < ContextualbarScrollableContent id = { formId } is = 'form' onSubmit = { handleSubmit ( handleSave ) } >
211209 < Field >
212- < FieldLabel htmlFor = { nameField } required >
213- { t ( 'Name' ) }
214- </ FieldLabel >
210+ < FieldLabel required > { t ( 'Name' ) } </ FieldLabel >
215211 < FieldRow >
216212 < Controller
217213 name = 'name'
218214 control = { control }
219215 rules = { { validate : validateName } }
220- render = { ( { field } ) => (
221- < TextInput
222- id = { nameField }
223- { ...field }
224- error = { errors . name ?. message }
225- aria-invalid = { errors . name ? 'true' : 'false' }
226- aria-describedby = { `${ nameField } -error` }
227- />
228- ) }
216+ render = { ( { field } ) => < TextInput { ...field } error = { errors . name ?. message } /> }
229217 />
230218 </ FieldRow >
231- { errors . name && (
232- < FieldError id = { `${ nameField } -error` } role = 'alert' >
233- { errors . name . message }
234- </ FieldError >
235- ) }
219+ { errors . name && < FieldError > { errors . name . message } </ FieldError > }
236220 </ Field >
237221 < Field >
238- < FieldLabel id = { emailField } > { t ( 'Email' ) } </ FieldLabel >
222+ < FieldLabel > { t ( 'Email' ) } </ FieldLabel >
239223 { emailFields . map ( ( field , index ) => (
240224 < Fragment key = { field . id } >
241225 < FieldRow >
@@ -246,24 +230,11 @@ const EditContactInfo = ({ contactData, onClose, onCancel }: ContactNewEditProps
246230 required : t ( 'Required_field' , { field : t ( 'Email' ) } ) ,
247231 validate : validateEmailFormat ,
248232 } }
249- render = { ( { field } ) => (
250- < TextInput
251- { ...field }
252- aria-labelledby = { emailField }
253- error = { errors . emails ?. [ index ] ?. address ?. message }
254- aria-invalid = { errors . emails ?. [ index ] ?. address ? 'true' : 'false' }
255- aria-describedby = { `${ emailField + index } -error` }
256- aria-required = 'true'
257- />
258- ) }
233+ render = { ( { field } ) => < TextInput { ...field } error = { errors . emails ?. [ index ] ?. address ?. message } aria-required = 'true' /> }
259234 />
260235 < IconButton title = { t ( 'Remove_email' ) } small onClick = { ( ) => removeEmail ( index ) } mis = { 8 } icon = 'trash' />
261236 </ FieldRow >
262- { errors . emails ?. [ index ] ?. address && (
263- < FieldError id = { `${ emailField + index } -error` } role = 'alert' >
264- { errors . emails ?. [ index ] ?. address ?. message }
265- </ FieldError >
266- ) }
237+ { errors . emails ?. [ index ] ?. address && < FieldError > { errors . emails ?. [ index ] ?. address ?. message } </ FieldError > }
267238 </ Fragment >
268239 ) ) }
269240 < Button
@@ -274,7 +245,7 @@ const EditContactInfo = ({ contactData, onClose, onCancel }: ContactNewEditProps
274245 </ Button >
275246 </ Field >
276247 < Field >
277- < FieldLabel id = { phoneField } > { t ( 'Phone' ) } </ FieldLabel >
248+ < FieldLabel > { t ( 'Phone' ) } </ FieldLabel >
278249 { phoneFields . map ( ( field , index ) => (
279250 < Fragment key = { field . id } >
280251 < FieldRow >
@@ -285,24 +256,11 @@ const EditContactInfo = ({ contactData, onClose, onCancel }: ContactNewEditProps
285256 required : t ( 'Required_field' , { field : t ( 'Phone' ) } ) ,
286257 validate : validatePhone ,
287258 } }
288- render = { ( { field } ) => (
289- < TextInput
290- { ...field }
291- aria-labelledby = { phoneField }
292- error = { errors . phones ?. [ index ] ?. phoneNumber ?. message }
293- aria-invalid = { errors . phones ?. [ index ] ?. phoneNumber ? 'true' : 'false' }
294- aria-describedby = { `${ phoneField + index } -error` }
295- aria-required = 'true'
296- />
297- ) }
259+ render = { ( { field } ) => < TextInput { ...field } error = { errors . phones ?. [ index ] ?. phoneNumber ?. message } aria-required = 'true' /> }
298260 />
299261 < IconButton title = { t ( 'Remove_phone' ) } small onClick = { ( ) => removePhone ( index ) } mis = { 8 } icon = 'trash' />
300262 </ FieldRow >
301- { errors . phones ?. [ index ] ?. phoneNumber && (
302- < FieldError id = { `${ phoneField + index } -error` } role = 'alert' >
303- { errors . phones ?. [ index ] ?. phoneNumber ?. message }
304- </ FieldError >
305- ) }
263+ { errors . phones ?. [ index ] ?. phoneNumber && < FieldError > { errors . phones ?. [ index ] ?. phoneNumber ?. message } </ FieldError > }
306264 </ Fragment >
307265 ) ) }
308266 < Button
0 commit comments