Skip to content

Commit 5fb16cb

Browse files
authored
Merge pull request #2703 from topcoder-platform/feature-profile-enhancements
Deploy feature-profile-enhancements to beta
2 parents 9da908f + cf4f516 commit 5fb16cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3357
-1352
lines changed
+6
Loading
Loading
Loading
Loading
Loading

src/shared/components/Settings/CofirmationModal/index.jsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ import { Modal, PrimaryButton, GhostButton } from 'topcoder-react-ui-kit';
44
import modal from './styles.scss';
55

66
export default function ConfirmationModal(props) {
7-
const { onConfirm, onCancel } = props;
7+
const { onConfirm, onCancel, name } = props;
88
return (
99
<Modal theme={modal}>
1010
<div styleName="modal.deletion-confirmation-container">
1111
<div styleName="modal.deletion-confirmation">
12-
<div styleName="modal.deletion-confirmation-title">Heads Up!</div>
12+
<div styleName="modal.deletion-confirmation-title">HEADS UP!</div>
1313
<div styleName="modal.deletion-confirmation-message">
14-
Are you sure you want to delete? This action can&apos;t be undone
15-
later.
14+
Are you sure you want to delete `{name}`? This action can&apos;t be undone.
1615
</div>
1716
<div styleName="modal.deletion-confirmation-buttons">
1817
<div styleName="modal.deletion-confirmation-button-yes">
@@ -31,4 +30,5 @@ export default function ConfirmationModal(props) {
3130
ConfirmationModal.propTypes = {
3231
onConfirm: PT.func.isRequired,
3332
onCancel: PT.func.isRequired,
33+
name: PT.string.isRequired,
3434
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
4+
import './styles.scss';
5+
6+
const marginTop = (value) => {
7+
if (value) {
8+
return 'active-margin';
9+
}
10+
11+
return 'active';
12+
};
13+
14+
const ErrorMessage = ({ invalid, message, addMargin }) => (
15+
<span styleName={`error-message ${invalid ? marginTop(addMargin) : ''}`}>
16+
{message}
17+
</span>
18+
);
19+
20+
ErrorMessage.defaultProps = {
21+
addMargin: false,
22+
};
23+
24+
ErrorMessage.propTypes = {
25+
invalid: PropTypes.bool.isRequired,
26+
message: PropTypes.string.isRequired,
27+
addMargin: PropTypes.bool,
28+
};
29+
30+
export default ErrorMessage;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@import "../style";
2+
3+
.error-message {
4+
display: none;
5+
6+
&.active {
7+
@include roboto-medium;
8+
9+
display: inline;
10+
border-radius: 5px;
11+
background-color: $tc-red-10;
12+
color: $tc-red-110;
13+
font-size: 15px;
14+
margin: 0 auto 0 0;
15+
}
16+
17+
&.active-margin {
18+
@include roboto-medium;
19+
20+
display: inline;
21+
border-radius: 5px;
22+
background-color: $tc-red-10;
23+
color: $tc-red-110;
24+
font-size: 15px;
25+
margin: 10px auto 0 0;
26+
}
27+
}

src/shared/components/Settings/Profile/BasicInfo/index.jsx

+12-29
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ import { PrimaryButton } from 'topcoder-react-ui-kit';
1515
import ConsentComponent from 'components/Settings/ConsentComponent';
1616
import Select from 'components/Select';
1717
import DatePicker from 'components/challenge-listing/Filters/DatePicker';
18+
import ErrorMessage from 'components/Settings/ErrorMessage';
1819
import ImageInput from '../ImageInput';
1920
import Track from './Track';
2021
import DefaultImageInput from './ImageInput';
2122
import dropdowns from './dropdowns.json';
2223
import tracks from './tracks';
2324

25+
2426
import './styles.scss';
2527

2628
export default class BasicInfo extends ConsentComponent {
@@ -41,7 +43,6 @@ export default class BasicInfo extends ConsentComponent {
4143
this.state = {
4244
inputChanged: false,
4345
formInvalid: false,
44-
errorMessage: '',
4546
basicInfoTrait: this.loadBasicInfoTraits(userTraits),
4647
personalizationTrait: this.loadPersonalizationTrait(userTraits),
4748
newBasicInfo: {
@@ -98,46 +99,26 @@ export default class BasicInfo extends ConsentComponent {
9899

99100
onCheckFormValue(newBasicInfo) {
100101
let invalid = false;
101-
let errorMessage = '';
102-
let dateError = '';
103-
let birthDateInvalid = false;
104-
const invalidFields = [];
105102

106103
if (!_.trim(newBasicInfo.firstName).length) {
107-
invalidFields.push('First Name');
108104
invalid = true;
109105
}
110106

111107
if (!_.trim(newBasicInfo.lastName).length) {
112-
invalidFields.push('Last Name');
113108
invalid = true;
114109
}
115110

116111
if (!_.trim(newBasicInfo.country).length) {
117-
invalidFields.push('Country');
118112
invalid = true;
119113
}
120114

121-
if (invalidFields.length > 0) {
122-
errorMessage += invalidFields.join(', ');
123-
errorMessage += ' cannot be empty';
124-
}
125-
126115
if (_.trim(newBasicInfo.birthDate).length > 0) {
127116
if (!moment().isAfter(newBasicInfo.birthDate)) {
128-
dateError = 'You must enter a valid date for Birth Date';
129-
birthDateInvalid = true;
117+
invalid = true;
130118
}
131119
}
132120

133-
if (errorMessage.length > 0) {
134-
errorMessage = `${errorMessage}. ${dateError}`;
135-
} else if (dateError.length > 0) {
136-
errorMessage = dateError;
137-
invalid = birthDateInvalid;
138-
}
139-
140-
this.setState({ errorMessage, formInvalid: invalid });
121+
this.setState({ formInvalid: invalid });
141122
return invalid;
142123
}
143124

@@ -170,7 +151,7 @@ export default class BasicInfo extends ConsentComponent {
170151
*/
171152
onHandleSaveBasicInfo(e) {
172153
e.preventDefault();
173-
this.setState({ isSaving: true });
154+
this.setState({ isSaving: true, inputChange: true });
174155
const { newBasicInfo } = this.state;
175156
if (this.onCheckFormValue(newBasicInfo)) {
176157
this.setState({ isSaving: false });
@@ -465,8 +446,7 @@ export default class BasicInfo extends ConsentComponent {
465446
render() {
466447
const {
467448
newBasicInfo,
468-
formInvalid,
469-
errorMessage,
449+
inputChanged,
470450
} = this.state;
471451

472452
const canModifyTrait = !this.props.traitRequestCount;
@@ -507,6 +487,7 @@ export default class BasicInfo extends ConsentComponent {
507487
<div styleName="field col-2">
508488
<span styleName="text-required">* Required</span>
509489
<input disabled={!canModifyTrait} id="firstName" name="firstName" type="text" placeholder="First Name" onChange={this.onUpdateInput} value={newBasicInfo.firstName} maxLength="64" required />
490+
<ErrorMessage invalid={_.isEmpty(newBasicInfo.firstName) && inputChanged} message="First Name cannot be empty" />
510491
</div>
511492
</div>
512493
<div styleName="row">
@@ -519,6 +500,7 @@ export default class BasicInfo extends ConsentComponent {
519500
<div styleName="field col-2">
520501
<span styleName="text-required">* Required</span>
521502
<input disabled={!canModifyTrait} id="lastName" name="lastName" type="text" placeholder="Last Name" onChange={this.onUpdateInput} value={newBasicInfo.lastName} maxLength="64" required />
503+
<ErrorMessage invalid={_.isEmpty(newBasicInfo.lastName) && inputChanged} message="Last Name cannot be empty" />
522504
</div>
523505
</div>
524506
<div styleName="row">
@@ -619,6 +601,7 @@ export default class BasicInfo extends ConsentComponent {
619601
disabled={!canModifyTrait}
620602
clearable={false}
621603
/>
604+
<ErrorMessage invalid={_.isEmpty(newBasicInfo.country) && inputChanged} message="Country cannot be empty" addMargin />
622605
</div>
623606
</div>
624607
</form>
@@ -745,6 +728,7 @@ export default class BasicInfo extends ConsentComponent {
745728
</label>
746729

747730
<input disabled={!canModifyTrait} id="firstNameId" name="firstName" type="text" placeholder="First Name" onChange={this.onUpdateInput} value={newBasicInfo.firstName} maxLength="64" required />
731+
<ErrorMessage invalid={_.isEmpty(newBasicInfo.firstName) && inputChanged} addMargin message="First Name cannot be empty" />
748732
</div>
749733
<div styleName="field">
750734
<label htmlFor="lastNameId">
@@ -753,6 +737,7 @@ export default class BasicInfo extends ConsentComponent {
753737
<input type="hidden" />
754738
</label>
755739
<input disabled={!canModifyTrait} id="lastNameId" name="lastName" type="text" placeholder="Last Name" onChange={this.onUpdateInput} value={newBasicInfo.lastName} maxLength="64" required />
740+
<ErrorMessage invalid={_.isEmpty(newBasicInfo.lastName) && inputChanged} addMargin message="Last Name cannot be empty" />
756741
</div>
757742
</div>
758743
</div>
@@ -826,6 +811,7 @@ export default class BasicInfo extends ConsentComponent {
826811
clearable={false}
827812
disabled={!canModifyTrait}
828813
/>
814+
<ErrorMessage invalid={_.isEmpty(newBasicInfo.country) && inputChanged} message="Country cannot be empty" />
829815
</div>
830816
</div>
831817
<div styleName="row">
@@ -931,9 +917,6 @@ export default class BasicInfo extends ConsentComponent {
931917
}
932918
</div>
933919
</div>
934-
<div styleName={`error-message ${formInvalid ? 'active' : ''}`}>
935-
{errorMessage}
936-
</div>
937920
<div styleName="button-save">
938921
<PrimaryButton
939922
styleName="white-label"

src/shared/components/Settings/Profile/BasicInfo/styles.scss

+2-33
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,6 @@
5252
}
5353
}
5454

55-
.error-message {
56-
display: none;
57-
58-
&.active {
59-
@include roboto-medium;
60-
61-
display: block;
62-
border-radius: 5px;
63-
background-color: $tc-red-10;
64-
color: $tc-red-110;
65-
font-size: 15px;
66-
padding: 15px;
67-
margin: 15px 0;
68-
}
69-
}
70-
7155
.form-container-default {
7256
@include form-container-default;
7357

@@ -181,22 +165,6 @@
181165
}
182166
}
183167

184-
.error-message {
185-
display: none;
186-
187-
&.active {
188-
@include roboto-medium;
189-
190-
display: block;
191-
border-radius: 5px;
192-
background-color: $tc-red-10;
193-
color: $tc-red-110;
194-
font-size: 15px;
195-
padding: 15px;
196-
margin-bottom: 15px;
197-
}
198-
}
199-
200168
.form-container {
201169
flex: 1;
202170
display: flex;
@@ -238,7 +206,8 @@
238206
margin-right: 10px;
239207

240208
@include upto-sm {
241-
display: block;
209+
display: flex;
210+
flex-direction: column;
242211
margin-right: 0;
243212
padding-bottom: 10px;
244213
}

0 commit comments

Comments
 (0)