Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/shared/components/Settings/Profile/BasicInfo/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default class BasicInfo extends ConsentComponent {

const { userTraits } = props;
this.state = {
componentMounted: false,
inputChanged: false,
formInvalid: false,
basicInfoTrait: this.loadBasicInfoTraits(userTraits),
Expand Down Expand Up @@ -81,6 +82,9 @@ export default class BasicInfo extends ConsentComponent {
const { basicInfoTrait } = this.state;
const basicInfo = basicInfoTrait.traits ? basicInfoTrait.traits.data[0] : {};
this.processBasicInfo(basicInfo);
this.setState({
componentMounted: true,
});
}

componentWillReceiveProps(nextProps) {
Expand Down Expand Up @@ -457,6 +461,7 @@ export default class BasicInfo extends ConsentComponent {
const {
newBasicInfo,
inputChanged,
componentMounted,
} = this.state;

const canModifyTrait = !this.props.traitRequestCount;
Expand Down Expand Up @@ -497,7 +502,7 @@ export default class BasicInfo extends ConsentComponent {
<div styleName="field col-2">
<span styleName="text-required">* Required</span>
<input disabled={!canModifyTrait} id="firstName" name="firstName" type="text" placeholder="First Name" onChange={this.onUpdateInput} value={newBasicInfo.firstName} maxLength="64" required />
<ErrorMessage invalid={_.isEmpty(newBasicInfo.firstName) && inputChanged} message="First Name cannot be empty" />
<ErrorMessage invalid={_.isEmpty(newBasicInfo.firstName) && componentMounted} message="First Name cannot be empty" />
</div>
</div>
<div styleName="row">
Expand All @@ -510,7 +515,7 @@ export default class BasicInfo extends ConsentComponent {
<div styleName="field col-2">
<span styleName="text-required">* Required</span>
<input disabled={!canModifyTrait} id="lastName" name="lastName" type="text" placeholder="Last Name" onChange={this.onUpdateInput} value={newBasicInfo.lastName} maxLength="64" required />
<ErrorMessage invalid={_.isEmpty(newBasicInfo.lastName) && inputChanged} message="Last Name cannot be empty" />
<ErrorMessage invalid={_.isEmpty(newBasicInfo.lastName) && componentMounted} message="Last Name cannot be empty" />
</div>
</div>
<div styleName="row">
Expand Down