Skip to content

Commit 0070ea1

Browse files
authored
Merge pull request #3284 from vigneshTheDev/profile-settings-alert-fix
fix for #3263
2 parents 8e0870a + e5be063 commit 0070ea1

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

src/routes/settings/routes/profile/components/ProfileSettingsForm.jsx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class ProfileSettingsForm extends Component {
2828
dirty: false,
2929
businessPhoneValid: true,
3030
countrySelected: null,
31+
businessPhoneDirty: false,
32+
countrySelectionDirty: false
3133
}
3234
this.onSubmit = this.onSubmit.bind(this)
3335
this.onValid = this.onValid.bind(this)
@@ -42,11 +44,12 @@ class ProfileSettingsForm extends Component {
4244
if (country && country.value && this.state.countrySelected !== country.value) {
4345
this.setState({
4446
countrySelected: country.value,
47+
countrySelectionDirty: true
4548
})
4649
}
4750
}
4851

49-
onBusinessPhoneCountryChange({ country }) {
52+
onBusinessPhoneCountryChange({ country, externalChange }) {
5053
const { businessPhoneValid } = this.state
5154

5255
if (country && country.code) {
@@ -68,6 +71,15 @@ class ProfileSettingsForm extends Component {
6871
businessPhoneValid: false
6972
})
7073
}
74+
75+
// external change means, the user didn't change the phone number field.
76+
// But it was automatically changed due to country selection change. In such case, we should show
77+
// the alert under country selection only.
78+
if (!externalChange) {
79+
this.setState({
80+
businessPhoneDirty: true
81+
})
82+
}
7183
}
7284

7385
getField(label, name, isRequired=false) {
@@ -108,6 +120,11 @@ class ProfileSettingsForm extends Component {
108120
...data,
109121
}
110122
this.props.saveSettings(updatedData)
123+
124+
this.setState({
125+
businessPhoneDirty: false,
126+
countrySelectionDirty: false
127+
})
111128
}
112129

113130
onValid() {
@@ -167,7 +184,10 @@ class ProfileSettingsForm extends Component {
167184
value={this.props.values.settings.businessPhone}
168185
onChangeCountry={this.onBusinessPhoneCountryChange}
169186
/>
170-
<div styleName="warningText">Note: Changing the country code also updates your country selection</div>
187+
{
188+
this.state.businessPhoneDirty &&
189+
<div styleName="warningText">Note: Changing the country code also updates your country selection</div>
190+
}
171191
</div>
172192
</div>
173193
{this.getField('Company name', 'companyName', true)}
@@ -219,7 +239,10 @@ class ProfileSettingsForm extends Component {
219239
showDropdownIndicator
220240
setValueOnly
221241
/>
222-
<div styleName="warningText">Note: Changing the country also updates the country code of business phone.</div>
242+
{
243+
this.state.countrySelectionDirty &&
244+
<div styleName="warningText">Note: Changing the country also updates the country code of business phone.</div>
245+
}
223246
</div>
224247
</div>
225248
<div className="controls">

src/routes/settings/routes/profile/components/ProfileSettingsForm.scss

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,16 @@
173173
}
174174

175175
.warningText {
176-
font-size: 12px;
177-
margin-top: 6px;
178-
color: $tc-red-100;
176+
margin: 5px auto;
177+
@include roboto;
178+
179+
color: $tc-gray-70;
180+
font-size: 13px;
181+
line-height:20px;
182+
font-style:italic;
183+
border: 1px solid $tc-red-30;
184+
background: $tc-red-10;
185+
color: $tc-red-70;
186+
padding:10px;
187+
border-radius: 2px;
179188
}

0 commit comments

Comments
 (0)