@@ -187,7 +187,7 @@ export default class Devices extends ConsentComponent {
187
187
* Invalid value, can not save
188
188
* @param newDevice object
189
189
*/
190
- onCheckFormValue ( newDevice ) {
190
+ onCheckFormValue ( newDevice , updateState = true ) {
191
191
let invalid = false ;
192
192
193
193
let errorMessage = '' ;
@@ -227,7 +227,9 @@ export default class Devices extends ConsentComponent {
227
227
errorMessage += ' cannot be empty' ;
228
228
}
229
229
230
- this . setState ( { errorMessage, formInvalid : invalid } ) ;
230
+ if ( updateState ) {
231
+ this . setState ( { errorMessage, formInvalid : invalid } ) ;
232
+ }
231
233
return invalid ;
232
234
}
233
235
@@ -282,13 +284,7 @@ export default class Devices extends ConsentComponent {
282
284
283
285
isFormValid ( ) {
284
286
const { newDevice } = this . state ;
285
- if ( ! newDevice . deviceType ) {
286
- valid = false ;
287
- }
288
- if ( newDevice . manufacturer . trim ( ) . length === 0 ) {
289
- valid = false ;
290
- }
291
- return this . onCheckFormValue ( newDevice ) ;
287
+ return this . onCheckFormValue ( newDevice , false ) ;
292
288
}
293
289
294
290
render ( ) {
@@ -299,7 +295,7 @@ export default class Devices extends ConsentComponent {
299
295
? deviceTrait . traits . data . slice ( ) : [ ] ;
300
296
const { newDevice, formInvalid, errorMessage } = this . state ;
301
297
const canModifyTrait = ! this . props . traitRequestCount ;
302
- const isValidDeviceForm = this . isFormValid ( ) ;
298
+ const isInValidDeviceForm = this . isFormValid ( ) ;
303
299
return (
304
300
< div styleName = "devices-container" >
305
301
{
@@ -423,7 +419,7 @@ export default class Devices extends ConsentComponent {
423
419
< PrimaryButton
424
420
styleName = "complete"
425
421
onClick = { this . onHandleAddDevice }
426
- disabled = { ! canModifyTrait }
422
+ disabled = { ! canModifyTrait || isInValidDeviceForm }
427
423
>
428
424
Add device to your list
429
425
</ PrimaryButton >
@@ -508,7 +504,7 @@ export default class Devices extends ConsentComponent {
508
504
< PrimaryButton
509
505
styleName = "complete"
510
506
onClick = { this . onHandleAddDevice }
511
- disabled = { ! canModifyTrait }
507
+ disabled = { ! canModifyTrait || isInValidDeviceForm }
512
508
>
513
509
Add Device
514
510
</ PrimaryButton >
0 commit comments