import { helpers } from 'rx'; import React, { PropTypes } from 'react'; import { reduxForm } from 'redux-form'; // import debug from 'debug'; import dedent from 'dedent'; import { isAscii, isEmail, isURL } from 'validator'; import { Button, Col, Input, Row } from 'react-bootstrap'; import { saveJob } from '../redux/actions'; // const log = debug('fcc:jobs:newForm'); const hightlightCopy = ` Highlight my post to make it stand out. (+$250) `; const isRemoteCopy = ` This job can be performed remotely. `; const howToApplyCopy = dedent` Examples: click here to apply yourcompany.com/jobs/33 Or email jobs@yourcompany.com `; const checkboxClass = dedent` text-left jobs-checkbox-spacer col-sm-offset-2 col-sm-6 col-md-offset-3 `; const certTypes = { isFrontEndCert: 'isFrontEndCert', isBackEndCert: 'isBackEndCert' }; function isValidURL(data) { return isURL(data, { 'require_protocol': true }); } const fields = [ 'position', 'locale', 'description', 'email', 'url', 'logo', 'company', 'isHighlighted', 'isRemoteOk', 'isFrontEndCert', 'isBackEndCert', 'howToApply' ]; const fieldValidators = { position: makeRequired(isAscii), locale: makeRequired(isAscii), description: makeRequired(helpers.identity), email: makeRequired(isEmail), url: isValidURL, logo: isValidURL, company: makeRequired(isAscii), howToApply: makeRequired(isAscii) }; function makeRequired(validator) { return (val) => !!val && validator(val); } function validateForm(values) { return Object.keys(fieldValidators) .map(field => { if (fieldValidators[field](values[field])) { return null; } return { [field]: fieldValidators[field](values[field]) }; }) .filter(Boolean) .reduce((errors, error) => ({ ...errors, ...error }), {}); } function getBsStyle(field) { if (field.pristine) { return null; } return field.error ? 'error' : 'success'; } export class NewJob extends React.Component { static displayName = 'NewJob'; static propTypes = { fields: PropTypes.object, handleSubmit: PropTypes.func }; componentDidMount() { // this.prop.getSavedForm(); } handleCertClick(name) { const { fields } = this.props; Object.keys(certTypes).forEach(certType => { if (certType === name) { return fields[certType].onChange(true); } fields[certType].onChange(false); }); } render() { const { fields: { position, locale, description, email, url, logo, company, isHighlighted, isRemoteOk, howToApply, isFrontEndCert, isBackEndCert }, handleSubmit } = this.props; const { handleChange } = this; const labelClass = 'col-sm-offset-1 col-sm-2'; const inputClass = 'col-sm-6'; return (
this.handleSubmit(data)) }>

First, select your ideal applicant:

Tell us about the position



How should they apply?


Tell us about your organization

handleChange('company', e) } type='text' wrapperClassName={ inputClass } { ...company } />

Make it stand out

Highlight this ad to give it extra attention.
Featured listings receive more clicks and more applications.
); } } export default reduxForm( { form: 'NewJob', fields, validate: validateForm }, null, { onSubmit: saveJob } )(NewJob);