@@ -15,6 +15,7 @@ import {
1515
1616// Types
1717import { Subscription } from 'src/types/subscriptions'
18+ import { handleValidation } from 'src/writeData/subscriptions/utils/form'
1819
1920interface Props {
2021 formContent : Subscription
@@ -30,47 +31,62 @@ const UserInput: FC<Props> = ({formContent, updateForm, className, edit}) => (
3031 margin = { ComponentSize . Large }
3132 className = { `${ className } -broker-form__creds` }
3233 >
33- < Form . Element label = "Username" >
34- < Input
35- type = { InputType . Text }
36- placeholder = "userName"
37- name = "username"
38- value = { formContent ?. brokerUsername ?? '' }
39- onChange = { e =>
40- updateForm ( {
41- ...formContent ,
42- brokerUsername : e . target . value ,
43- } )
44- }
45- testID = { `${ className } -broker-form--username` }
46- status = {
47- edit || className === 'create'
48- ? ComponentStatus . Default
49- : ComponentStatus . Disabled
50- }
51- maxLength = { 255 }
52- />
53- </ Form . Element >
54- < Form . Element label = "Password" >
55- < Input
56- type = { InputType . Password }
57- placeholder = "*********"
58- name = "password"
59- value = { formContent ?. brokerPassword ?? '' }
60- onChange = { e =>
61- updateForm ( {
62- ...formContent ,
63- brokerPassword : e . target . value ,
64- } )
65- }
66- testID = { `${ className } -broker-form--password` }
67- status = {
68- edit || className === 'create'
69- ? ComponentStatus . Default
70- : ComponentStatus . Disabled
71- }
72- />
73- </ Form . Element >
34+ < Form . ValidationElement
35+ label = "Username"
36+ required = { true }
37+ validationFunc = { ( ) =>
38+ handleValidation ( 'Username' , formContent . brokerUsername )
39+ }
40+ value = { formContent . brokerUsername }
41+ >
42+ { status => (
43+ < Input
44+ type = { InputType . Text }
45+ placeholder = "username"
46+ name = "username"
47+ value = { formContent ?. brokerUsername ?? '' }
48+ onChange = { e =>
49+ updateForm ( {
50+ ...formContent ,
51+ brokerUsername : e . target . value ,
52+ } )
53+ }
54+ testID = { `${ className } -broker-form--username` }
55+ status = {
56+ edit || className === 'create' ? status : ComponentStatus . Disabled
57+ }
58+ maxLength = { 255 }
59+ />
60+ ) }
61+ </ Form . ValidationElement >
62+ < Form . ValidationElement
63+ label = "Password"
64+ required = { true }
65+ value = { formContent . brokerPassword }
66+ validationFunc = { ( ) =>
67+ handleValidation ( 'Password' , formContent . brokerPassword )
68+ }
69+ >
70+ { status => (
71+ < Input
72+ type = { InputType . Password }
73+ placeholder = "*********"
74+ name = "password"
75+ required = { true }
76+ value = { formContent ?. brokerPassword ?? '' }
77+ onChange = { e =>
78+ updateForm ( {
79+ ...formContent ,
80+ brokerPassword : e . target . value ,
81+ } )
82+ }
83+ testID = { `${ className } -broker-form--password` }
84+ status = {
85+ edit || className === 'create' ? status : ComponentStatus . Disabled
86+ }
87+ />
88+ ) }
89+ </ Form . ValidationElement >
7490 </ FlexBox >
7591)
7692export default UserInput
0 commit comments