@@ -11,6 +11,9 @@ import { connect } from 'react-redux';
11
11
import { isValidEmail } from 'utils/tc' ;
12
12
import techSkills from './techSkills' ;
13
13
14
+ const countries = require ( 'i18n-iso-countries' ) ;
15
+ countries . registerLocale ( require ( 'i18n-iso-countries/langs/en.json' ) ) ;
16
+
14
17
class RecruitCRMJobApplyContainer extends React . Component {
15
18
constructor ( props ) {
16
19
super ( props ) ;
@@ -26,6 +29,7 @@ class RecruitCRMJobApplyContainer extends React.Component {
26
29
{ label : '10 hours' , checked : false } , { label : '20 hours' , checked : false } , { label : '30 hours' , checked : false } , { label : '40 hours' , checked : false } ,
27
30
] ,
28
31
agreedTerms : false ,
32
+ country : _ . map ( countries . getNames ( 'en' ) , val => ( { label : val , selected : false } ) ) ,
29
33
// eslint-disable-next-line react/destructuring-assignment
30
34
} ,
31
35
} ;
@@ -69,14 +73,17 @@ class RecruitCRMJobApplyContainer extends React.Component {
69
73
const { formData, formErrors } = state ;
70
74
// Form validation happens here
71
75
const requiredTextFields = [
72
- 'fname' , 'lname' , 'city' , 'country' , ' reffereal', 'phone' , 'email' ,
76
+ 'fname' , 'lname' , 'city' , 'reffereal' , 'phone' , 'email' ,
73
77
] ;
74
78
// check required text fields for value
75
79
_ . each ( requiredTextFields , ( key ) => {
76
80
if ( ! formData [ key ] || ! _ . trim ( formData [ key ] ) ) formErrors [ key ] = 'Required field' ;
77
81
else if ( formData [ key ] && _ . trim ( formData [ key ] ) . length < 2 ) formErrors [ key ] = 'Must be at least 2 characters' ;
78
82
else delete formErrors [ key ] ;
79
83
} ) ;
84
+ // check for selected country
85
+ if ( ! _ . find ( formData . country , { selected : true } ) ) formErrors . country = 'Please, select your country' ;
86
+ else delete formErrors . country ;
80
87
// check payExpectation to be a number
81
88
if ( formData . payExpectation && _ . trim ( formData . payExpectation ) ) {
82
89
if ( ! _ . isInteger ( _ . toNumber ( formData . payExpectation ) ) ) formErrors . payExpectation = 'Must be integer value in $' ;
0 commit comments