@@ -80,17 +80,20 @@ export default class BasicInfo extends ConsentComponent {
8080
8181 componentWillReceiveProps ( nextProps ) {
8282 const basicInfoTrait = this . loadBasicInfoTraits ( nextProps . userTraits ) ;
83+
8384 const basicInfo = basicInfoTrait . traits ? basicInfoTrait . traits . data [ 0 ] : { } ;
85+ const previousBasicInfoTrait = this . loadBasicInfoTraits ( this . props . userTraits ) ;
86+
8487 const personalizationTrait = this . loadPersonalizationTrait ( nextProps . userTraits ) ;
85- if ( basicInfoTrait . updatedAt !== this . loadBasicInfoTraits ( this . props . userTraits ) . updatedAt ) {
88+ if ( ! _ . isEqual ( basicInfoTrait , previousBasicInfoTrait ) ) {
8689 this . processBasicInfo ( basicInfo , nextProps . profile ) ;
8790 this . setState ( {
8891 basicInfoTrait,
8992 personalizationTrait,
9093 inputChanged : false ,
9194 } ) ;
9295 }
93- if ( this . state . profile . updatedAt !== nextProps . profile . updatedAt ) {
96+ if ( ! _ . isEqual ( this . state . profile , nextProps . profile ) ) {
9497 this . processBasicInfo ( basicInfo , nextProps . profile ) ;
9598 this . setState ( { profile : nextProps . profile } ) ;
9699 }
@@ -121,6 +124,10 @@ export default class BasicInfo extends ConsentComponent {
121124 invalid = true ;
122125 }
123126
127+ if ( ! _ . trim ( newProfileInfo . description ) . length ) {
128+ invalid = true ;
129+ }
130+
124131 if ( _ . trim ( newBasicInfo . birthDate ) . length > 0 ) {
125132 if ( ! moment ( ) . isAfter ( newBasicInfo . birthDate ) ) {
126133 invalid = true ;
@@ -280,6 +287,15 @@ export default class BasicInfo extends ConsentComponent {
280287 case 'city' :
281288 case 'streetAddr1' :
282289 case 'streetAddr2' :
290+ if ( newProfileInfo . addresses . length === 0 ) {
291+ newProfileInfo . addresses . push ( {
292+ stateCode : '' ,
293+ zip : '' ,
294+ city : '' ,
295+ streetAddr1 : '' ,
296+ streetAddr2 : '' ,
297+ } ) ;
298+ }
283299 newProfileInfo . addresses [ 0 ] [ name ] = value ;
284300 break ;
285301 case 'firstName' :
@@ -388,6 +404,7 @@ export default class BasicInfo extends ConsentComponent {
388404
389405 const invalid = ! _ . trim ( newProfileInfo . firstName ) . length
390406 || ! _ . trim ( newProfileInfo . lastName ) . length
407+ || ! _ . trim ( newProfileInfo . description ) . length
391408 || ! _ . trim ( newBasicInfo . gender ) . length
392409 || ! _ . trim ( newBasicInfo . tshirtSize ) . length
393410 || ! _ . trim ( newBasicInfo . country ) . length
@@ -399,6 +416,7 @@ export default class BasicInfo extends ConsentComponent {
399416 || ( addresses . length > 0 && ! _ . trim ( addresses [ 0 ] . zip ) . length )
400417 || ( addresses . length > 0
401418 && ! _ . trim ( addresses [ 0 ] . streetAddr1 ) . length ) ;
419+
402420 // Invalid value, can not save
403421 if ( invalid ) {
404422 return true ;
@@ -498,7 +516,7 @@ export default class BasicInfo extends ConsentComponent {
498516 </ label >
499517 </ div >
500518 < div styleName = "field col-2" >
501- < input disabled = { ! canModifyTrait } id = "address" name = "streetAddr1" type = "text" placeholder = "Your address" onChange = { this . onUpdateInput } value = { `${ newProfileInfo . addresses . length > 0 ? newProfileInfo . addresses [ 0 ] . streetAddr1 : '' } ` } maxLength = "64" required />
519+ < input disabled = { ! canModifyTrait } id = "address" name = "streetAddr1" type = "text" placeholder = "Your address" onChange = { this . onUpdateInput } value = { `${ newProfileInfo . addresses . length > 0 && newProfileInfo . addresses [ 0 ] . streetAddr1 != null ? newProfileInfo . addresses [ 0 ] . streetAddr1 : '' } ` } maxLength = "64" required />
502520 </ div >
503521 </ div >
504522 < div styleName = "row" >
@@ -509,7 +527,7 @@ export default class BasicInfo extends ConsentComponent {
509527 </ label >
510528 </ div >
511529 < div styleName = "field col-2" >
512- < input disabled = { ! canModifyTrait } id = "address" name = "streetAddr2" type = "text" styleName = "second-addr" placeholder = "Your address continued" onChange = { this . onUpdateInput } value = { `${ newProfileInfo . addresses . length > 0 ? newProfileInfo . addresses [ 0 ] . streetAddr2 : '' } ` } maxLength = "64" />
530+ < input disabled = { ! canModifyTrait } id = "address" name = "streetAddr2" type = "text" styleName = "second-addr" placeholder = "Your address continued" onChange = { this . onUpdateInput } value = { `${ newProfileInfo . addresses . length > 0 && newProfileInfo . addresses [ 0 ] . streetAddr2 != null ? newProfileInfo . addresses [ 0 ] . streetAddr2 : '' } ` } maxLength = "64" />
513531 </ div >
514532 </ div >
515533 < div styleName = "row" >
@@ -520,7 +538,7 @@ export default class BasicInfo extends ConsentComponent {
520538 </ label >
521539 </ div >
522540 < div styleName = "field col-2" >
523- < input disabled = { ! canModifyTrait } id = "city" name = "city" type = "text" placeholder = "Which city do you live in?" onChange = { this . onUpdateInput } value = { `${ newProfileInfo . addresses . length > 0 ? newProfileInfo . addresses [ 0 ] . city : '' } ` } maxLength = "64" required />
541+ < input disabled = { ! canModifyTrait } id = "city" name = "city" type = "text" placeholder = "Which city do you live in?" onChange = { this . onUpdateInput } value = { `${ newProfileInfo . addresses . length > 0 && newProfileInfo . addresses [ 0 ] . city != null ? newProfileInfo . addresses [ 0 ] . city : '' } ` } maxLength = "64" required />
524542 </ div >
525543 </ div >
526544 < div styleName = "row" >
@@ -531,7 +549,7 @@ export default class BasicInfo extends ConsentComponent {
531549 </ label >
532550 </ div >
533551 < div styleName = "field col-2" >
534- < input disabled = { ! canModifyTrait } id = "state" name = "stateCode" type = "text" placeholder = "State" onChange = { this . onUpdateInput } value = { `${ newProfileInfo . addresses . length > 0 ? newProfileInfo . addresses [ 0 ] . stateCode : '' } ` } maxLength = "64" required />
552+ < input disabled = { ! canModifyTrait } id = "state" name = "stateCode" type = "text" placeholder = "State" onChange = { this . onUpdateInput } value = { `${ newProfileInfo . addresses . length > 0 && newProfileInfo . addresses [ 0 ] . stateCode != null ? newProfileInfo . addresses [ 0 ] . stateCode : '' } ` } maxLength = "64" required />
535553 </ div >
536554 </ div >
537555 < div styleName = "row" >
@@ -542,7 +560,7 @@ export default class BasicInfo extends ConsentComponent {
542560 </ label >
543561 </ div >
544562 < div styleName = "field col-2" >
545- < input disabled = { ! canModifyTrait } id = "zipCode" name = "zip" type = "text" placeholder = "ZIP/Postal Code" onChange = { this . onUpdateInput } value = { `${ newProfileInfo . addresses . length > 0 ? newProfileInfo . addresses [ 0 ] . zip : '' } ` } maxLength = "64" required />
563+ < input disabled = { ! canModifyTrait } id = "zipCode" name = "zip" type = "text" placeholder = "ZIP/Postal Code" onChange = { this . onUpdateInput } value = { `${ newProfileInfo . addresses . length > 0 && newProfileInfo . addresses [ 0 ] . zip != null ? newProfileInfo . addresses [ 0 ] . zip : '' } ` } maxLength = "64" required />
546564 </ div >
547565 </ div >
548566 < div styleName = "row" >
@@ -655,6 +673,7 @@ export default class BasicInfo extends ConsentComponent {
655673 </ span >
656674 </ div >
657675 < textarea disabled = { ! canModifyTrait } id = "description" styleName = "bio-text" name = "description" placeholder = "In 240 characters or less, tell the Topcoder community a bit about yourself" onChange = { this . onUpdateInput } value = { newProfileInfo . description } maxLength = "240" cols = "3" rows = "10" />
676+ < ErrorMessage invalid = { _ . isEmpty ( newProfileInfo . description ) && inputChanged } message = "Short bio cannot be empty" addMargin />
658677 </ div >
659678 </ div >
660679 </ form >
0 commit comments