Skip to content

Commit 7641323

Browse files
committed
Country dropdown
1 parent 4de51d2 commit 7641323

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

src/shared/actions/recruitCRM.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { redux } from 'topcoder-react-utils';
22
import Service from 'services/recruitCRM';
3+
import _ from 'lodash';
34

45
/**
56
* Jobs page fetch init
@@ -58,7 +59,7 @@ function normalizeRecruitPayload(payload) {
5859
email: payload.email,
5960
contact_number: payload.phone,
6061
city: payload.city,
61-
locality: payload.country,
62+
locality: _.find(payload.country, { selected: true }).label,
6263
available_from: payload.availFrom,
6364
salary_expectation: payload.payExpectation,
6465
skill: payload.skills.filter(s => s.selected).map(s => s.label).join(','),

src/shared/components/GUIKit/Dropdown/style.scss

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
padding-top: 12px;
2828

2929
&.haveValue .label,
30+
&.haveError .label,
3031
&.isFocused .label {
3132
display: flex;
3233
}

src/shared/components/Gigs/GigApply/index.jsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Checkbox from 'components/GUIKit/Checkbox';
1414
import { getCustomField } from 'utils/gigs';
1515
import Modal from 'components/Contentful/Modal';
1616
import FilestackFilePicker from 'components/GUIKit/FilePicker';
17+
import Dropdown from 'components/GUIKit/Dropdown';
1718
import './style.scss';
1819
import bigCheckmark from 'assets/images/big-checkmark.png';
1920
import SadFace from 'assets/images/sad-face-icon.svg';
@@ -72,7 +73,7 @@ export default function GigApply(props) {
7273
}
7374
{
7475
!application ? (
75-
<div styleName="form-wrap">
76+
<div styleName={`form-wrap ${applying ? 'applying' : ''}`}>
7677
<h4>PERSONAL INFORMATION</h4>
7778
<p>Welcome to Topcoder Gigs! We’d like to get to know you.</p>
7879
<div styleName="form-section">
@@ -121,12 +122,12 @@ export default function GigApply(props) {
121122
value={formData.city}
122123
required
123124
/>
124-
<TextInput
125+
<Dropdown
125126
placeholder="Country"
126127
label="Country"
127128
onChange={val => onFormInputChange('country', val)}
128129
errorMsg={formErrors.country}
129-
value={formData.country}
130+
options={formData.country}
130131
required
131132
/>
132133
</div>

src/shared/components/Gigs/GigApply/style.scss

+5
Original file line numberDiff line numberDiff line change
@@ -245,4 +245,9 @@
245245
}
246246
/* stylelint-enable */
247247
}
248+
249+
.form-wrap.applying .form-section {
250+
opacity: 0.6;
251+
pointer-events: none !important;
252+
}
248253
}

src/shared/containers/Gigs/RecruitCRMJobApply.jsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import { connect } from 'react-redux';
1111
import { isValidEmail } from 'utils/tc';
1212
import techSkills from './techSkills';
1313

14+
const countries = require('i18n-iso-countries');
15+
countries.registerLocale(require('i18n-iso-countries/langs/en.json'));
16+
1417
class RecruitCRMJobApplyContainer extends React.Component {
1518
constructor(props) {
1619
super(props);
@@ -26,6 +29,7 @@ class RecruitCRMJobApplyContainer extends React.Component {
2629
{ label: '10 hours', checked: false }, { label: '20 hours', checked: false }, { label: '30 hours', checked: false }, { label: '40 hours', checked: false },
2730
],
2831
agreedTerms: false,
32+
country: _.map(countries.getNames('en'), val => ({ label: val, selected: false })),
2933
// eslint-disable-next-line react/destructuring-assignment
3034
},
3135
};
@@ -69,14 +73,17 @@ class RecruitCRMJobApplyContainer extends React.Component {
6973
const { formData, formErrors } = state;
7074
// Form validation happens here
7175
const requiredTextFields = [
72-
'fname', 'lname', 'city', 'country', 'reffereal', 'phone', 'email',
76+
'fname', 'lname', 'city', 'reffereal', 'phone', 'email',
7377
];
7478
// check required text fields for value
7579
_.each(requiredTextFields, (key) => {
7680
if (!formData[key] || !_.trim(formData[key])) formErrors[key] = 'Required field';
7781
else if (formData[key] && _.trim(formData[key]).length < 2) formErrors[key] = 'Must be at least 2 characters';
7882
else delete formErrors[key];
7983
});
84+
// check for selected country
85+
if (!_.find(formData.country, { selected: true })) formErrors.country = 'Please, select your country';
86+
else delete formErrors.country;
8087
// check payExpectation to be a number
8188
if (formData.payExpectation && _.trim(formData.payExpectation)) {
8289
if (!_.isInteger(_.toNumber(formData.payExpectation))) formErrors.payExpectation = 'Must be integer value in $';

0 commit comments

Comments
 (0)