Add required fields to job form

This commit is contained in:
Berkeley Martinez
2015-10-11 21:11:27 -07:00
parent e4e87fd1a1
commit 1f16d6f5d9
3 changed files with 16 additions and 6 deletions

View File

@ -58,6 +58,10 @@ function isValidPhone(data) {
return isMobilePhone(data, 'en-US'); return isMobilePhone(data, 'en-US');
} }
function makeRequired(validator) {
return (val) => !!val && validator(val);
}
export default contain({ export default contain({
actions: 'jobActions', actions: 'jobActions',
store: 'jobsStore', store: 'jobsStore',
@ -74,14 +78,14 @@ export default contain({
highlight highlight
} = form; } = form;
return { return {
position: formatValue(position, isAscii), position: formatValue(position, makeRequired(isAscii)),
locale: formatValue(locale, isAscii), locale: formatValue(locale, makeRequired(isAscii)),
description: formatValue(description, isAscii), description: formatValue(description, makeRequired(isAscii)),
email: formatValue(email, isEmail), email: formatValue(email, makeRequired(isEmail)),
phone: formatValue(phone, isValidPhone), phone: formatValue(phone, isValidPhone),
url: formatValue(url, isValidURL), url: formatValue(url, isValidURL),
logo: formatValue(logo, isValidURL), logo: formatValue(logo, isValidURL),
name: formatValue(name, isAscii), name: formatValue(name, makeRequired(isAscii)),
highlight: formatValue(highlight, null, 'bool') highlight: formatValue(highlight, null, 'bool')
}; };
}, },
@ -209,6 +213,7 @@ export default contain({
labelClassName={ labelClass } labelClassName={ labelClass }
onChange={ (e) => handleChange('position', e) } onChange={ (e) => handleChange('position', e) }
placeholder='Position' placeholder='Position'
required={ true }
type='text' type='text'
value={ position.value } value={ position.value }
wrapperClassName={ inputClass } /> wrapperClassName={ inputClass } />
@ -218,6 +223,7 @@ export default contain({
labelClassName={ labelClass } labelClassName={ labelClass }
onChange={ (e) => handleChange('locale', e) } onChange={ (e) => handleChange('locale', e) }
placeholder='Location' placeholder='Location'
required={ true }
type='text' type='text'
value={ locale.value } value={ locale.value }
wrapperClassName={ inputClass } /> wrapperClassName={ inputClass } />
@ -227,6 +233,7 @@ export default contain({
labelClassName={ labelClass } labelClassName={ labelClass }
onChange={ (e) => handleChange('description', e) } onChange={ (e) => handleChange('description', e) }
placeholder='Description' placeholder='Description'
required={ true }
rows='10' rows='10'
type='textarea' type='textarea'
value={ description.value } value={ description.value }
@ -250,6 +257,7 @@ export default contain({
labelClassName={ labelClass } labelClassName={ labelClass }
onChange={ (e) => handleChange('email', e) } onChange={ (e) => handleChange('email', e) }
placeholder='Email' placeholder='Email'
required={ true }
type='email' type='email'
value={ email.value } value={ email.value }
wrapperClassName={ inputClass } /> wrapperClassName={ inputClass } />

View File

@ -40,6 +40,7 @@ export default React.createClass({
city, city,
company, company,
state, state,
locale,
email, email,
phone, phone,
postedOn, postedOn,
@ -57,7 +58,7 @@ export default React.createClass({
<Panel> <Panel>
Position: { position || 'N/A' } Position: { position || 'N/A' }
<br /> <br />
Location: { city || '' }, { state || 'N/A' } Location: { locale ? locale : `${city}, ${state}` }
<br /> <br />
Contact: { email || phone || 'N/A' } Contact: { email || phone || 'N/A' }
<br /> <br />

View File

@ -57,6 +57,7 @@ export default Actions({
saveForm: null, saveForm: null,
getSavedForm: null, getSavedForm: null,
setForm(form) { setForm(form) {
form.locale = form.location;
return { form }; return { form };
} }
}) })