@@ -77,7 +77,7 @@ const AddWorkspace = () => {
77
77
}
78
78
} ;
79
79
80
- const validate : _VALIDATE_PROPS = ( name , value , files ) => {
80
+ const validate : _VALIDATE_PROPS = ( name , value ) => {
81
81
switch ( name ) {
82
82
case 'workspace' :
83
83
if ( ! value ) {
@@ -88,11 +88,6 @@ const AddWorkspace = () => {
88
88
return 'Workspace name already exist' ;
89
89
}
90
90
return '' ;
91
- case 'image' :
92
- if ( ! FileList ) {
93
- return 'File is required' ;
94
- }
95
- return '' ;
96
91
case 'description' :
97
92
if ( value . length > 200 ) {
98
93
return 'Description should be less then 200 characters' ;
@@ -122,8 +117,8 @@ const AddWorkspace = () => {
122
117
}
123
118
} ;
124
119
const handleBlur = ( e : React . FocusEvent < HTMLInputElement > ) => {
125
- const { name, value, files } = e . target ;
126
- const error = validate ( name , value , files ) ;
120
+ const { name, value } = e . target ;
121
+ const error = validate ( name , value ) ;
127
122
setFormErrors ( {
128
123
...formErrors ,
129
124
[ name ] : error ,
@@ -132,17 +127,18 @@ const AddWorkspace = () => {
132
127
133
128
const handleSubmit : _FORM_SUBMIT = ( event ) => {
134
129
event . preventDefault ( ) ;
135
- const workspace_error = validate ( 'workspace' , form . workspace , null ) ;
136
- const desc_error = validate ( 'description' , form . description , null ) ;
137
- const image_error = form . image ? '' : 'Image is required' ;
130
+ const workspace_error = validate ( 'workspace' , form . workspace ) ;
131
+ const desc_error = validate ( 'description' , form . description ) ;
138
132
setFormErrors ( {
139
133
...formErrors ,
140
134
workspace : workspace_error ,
141
135
description : desc_error ,
142
- image : image_error ,
143
136
} ) ;
144
- if ( workspace_error || desc_error || image_error )
145
- toast . error ( 'Check workspace, icon and description fields' ) ;
137
+ if ( workspace_error || desc_error ) {
138
+ if ( workspace_error )
139
+ toast . error ( 'Check workspace field' ) ;
140
+ if ( desc_error ) toast . error ( "Check description field" )
141
+ }
146
142
else {
147
143
if ( token ) {
148
144
const newForm = form ;
@@ -222,7 +218,7 @@ const AddWorkspace = () => {
222
218
>
223
219
< div className = 'single-form-element-container' >
224
220
< p className = 'label' >
225
- Add Icon< span style = { { color : 'red' , paddingLeft : '4px' } } > * </ span >
221
+ Add Icon
226
222
</ p >
227
223
< div className = 'file-input-container' >
228
224
< label htmlFor = 'icon-file' className = 'file-label' >
@@ -242,7 +238,6 @@ const AddWorkspace = () => {
242
238
< p > Supported formats: JPEG, JPG, PNG</ p >
243
239
< p > Selected File: { form . image ?. name } </ p >
244
240
</ div >
245
- { formErrors . image && < p className = 'form-error' > { formErrors . image } </ p > }
246
241
</ div >
247
242
< div className = 'single-form-element-container' >
248
243
< label className = 'label' htmlFor = 'workspace-name' >
@@ -302,8 +297,8 @@ const AddWorkspace = () => {
302
297
type = 'button'
303
298
disabled = {
304
299
form . member
305
- ? ! users . includes ( form . member ) &&
306
- form . member == userContext ?. username
300
+ ? ( ! users . includes ( form . member ) &&
301
+ form . member == userContext ?. username )
307
302
: true
308
303
}
309
304
>
0 commit comments