Skip to content

Instantly share code, notes, and snippets.

@fayimora
Created December 21, 2016 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fayimora/011a2b28c56ab89019933fb5bdda1b65 to your computer and use it in GitHub Desktop.
Save fayimora/011a2b28c56ab89019933fb5bdda1b65 to your computer and use it in GitHub Desktop.
import React, { PropTypes } from 'react';
import TextInput from '../common/TextInput';
import SelectInput from '../common/SelectInput';
const CourseForm = ({course, allAuthors, onSave, onChange, loading, errors}) => {
return (
<form>
<h1>Manage Course</h1>
<TextInput
name="title"
label="Title"
value={course.title}
onChange={onChange}
error={errors.title}/>
<SelectInput
name="authorId"
label="Author"
value={course.authorId}
defaultOption="Select Author"
options={allAuthors}
onChange={onChange}
error={errors.authorId}/>
<TextInput
name="category"
label="Category"
value={course.category}
onChange={onChange}
error={errors.category}/>
<TextInput
name="length"
label="Length"
value={course.length}
onChange={onChange}
error={errors.length}/>
<input
type="submit"
disabled={loading}
value={loading ? 'Saving...' : 'Save'}
className="btn btn-primary"
onClick={onSave}/>
</form>
);
};
CourseForm.propTypes = {
course: PropTypes.object.isRequired,
allAuthors: PropTypes.array,
onSave: PropTypes.func.isRequired,
onChange: PropTypes.func.isRequired,
loading: PropTypes.bool,
errors: PropTypes.object
};
export default CourseForm;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment