diff --git a/common/app/routes/Jobs/components/NewJob.jsx b/common/app/routes/Jobs/components/NewJob.jsx index 83f773e05d..ae1e5eab51 100644 --- a/common/app/routes/Jobs/components/NewJob.jsx +++ b/common/app/routes/Jobs/components/NewJob.jsx @@ -8,7 +8,8 @@ import { } from 'react-bootstrap'; import { isAscii, - isEmail + isEmail, + isMobilePhone } from 'validator'; const defaults = { @@ -31,13 +32,15 @@ export default contain({ position = defaultValue('string'), locale = defaultValue('string'), description = defaultValue('string'), - email = defaultValue('string') + email = defaultValue('string'), + phone = defaultValue('string') } = form; return { position, locale, description, - email + email, + phone }; } }, @@ -49,17 +52,25 @@ export default contain({ position: PropTypes.object, locale: PropTypes.object, description: PropTypes.object, - email: PropTypes.object + email: PropTypes.object, + phone: PropTypes.object + }, + + handleChange(name, validator, { target: { value } }) { + const { jobActions: { handleForm } } = this.props; + handleForm({ name, value, validator }); }, render() { const { - jobActions, position, locale, description, - email + email, + phone } = this.props; + const labelClass = 'col-sm-offset-1 col-sm-2'; + const inputClass = 'col-sm-6'; return (
@@ -68,67 +79,90 @@ export default contain({

Create Your Job Post

- { - jobActions.handleForm({ - name: 'position', - value, - validator: isAscii - }); - }} - placeholder='Position' - type='text' - value={ position.value } - wrapperClassName='col-xs-10' /> - { - jobActions.handleForm({ - name: 'locale', - value, - validator: isAscii - }); - }} - placeholder='Location' - type='text' - value={ locale.value } - wrapperClassName='col-xs-10' /> - { - jobActions.handleForm({ - name: 'description', - value, - validator: isAscii - }); - }} - placeholder='Description' - rows='10' - type='textarea' - value={ description.value } - wrapperClassName='col-xs-10' /> - { - jobActions.handleForm({ - name: 'email', - value, - validator: isEmail - }); - }} - placeholder='Email' - type='email' - value={ email.value } - wrapperClassName='col-xs-10' /> + +
+

Job Information

+
+ { + this.handleChange( + 'position', + isAscii, + e + ); + }} + placeholder='Position' + type='text' + value={ position.value } + wrapperClassName={ inputClass } /> + { + this.handleChange( + 'locale', + isAscii, + e, + ); + }} + placeholder='Location' + type='text' + value={ locale.value } + wrapperClassName={ inputClass } /> + { + this.handleChange( + 'description', + isAscii, + e + ); + }} + placeholder='Description' + rows='10' + type='textarea' + value={ description.value } + wrapperClassName={ inputClass } /> +
+

Company Information

+
+ { + this.handleChange( + 'email', + isEmail, + e + ); + }} + placeholder='Email' + type='email' + value={ email.value } + wrapperClassName={ inputClass } /> + { + this.handleChange( + 'phone', + (data) => isMobilePhone(data, 'en-US'), + e + ); + }} + placeholder='555-123-1234' + type='tel' + value={ phone.value } + wrapperClassName={ inputClass } /> +
diff --git a/common/models/job.json b/common/models/job.json index a3392fee82..197f0619bf 100644 --- a/common/models/job.json +++ b/common/models/job.json @@ -1,6 +1,7 @@ { "name": "job", "base": "PersistedModel", + "strict": true, "idInjection": true, "trackChanges": false, "properties": { diff --git a/package.json b/package.json index 16c58aae82..df579eb2bc 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ "thundercats-react": "^0.1.0", "twit": "~1.1.20", "uglify-js": "~2.4.15", - "validator": "~3.22.1", + "validator": "^3.22.1", "webpack": "^1.9.12", "yui": "~3.18.1" },