diff --git a/bikeshop_project/assets/js/bikes/components/BikeForm/index.jsx b/bikeshop_project/assets/js/bikes/components/BikeForm/index.jsx index 32f6c8e..6dbae35 100644 --- a/bikeshop_project/assets/js/bikes/components/BikeForm/index.jsx +++ b/bikeshop_project/assets/js/bikes/components/BikeForm/index.jsx @@ -1,17 +1,10 @@ import React, { PropTypes } from 'react'; import { Field, formValueSelector, reduxForm } from 'redux-form'; import { connect } from 'react-redux'; -import Checkbox from 'material-ui/Checkbox'; -import Cookies from 'js-cookie'; import FlatButton from 'material-ui/FlatButton'; -import MenuItem from 'material-ui/MenuItem'; import RaisedButton from 'material-ui/RaisedButton'; -import SelectField from 'material-ui/SelectField'; -import TextField from 'material-ui/TextField'; -import fetch from 'isomorphic-fetch'; -import moment from 'moment-timezone'; -import Source from '../Source'; import Size from '../Size'; +import { renderCheckbox, renderSelectField, renderTextField } from './utils'; import { updateBike, saveBike, checkCpic } from '../../actions'; const styles = { @@ -26,51 +19,7 @@ const styles = { }, }; -const sources = ['COS_BIKE_DIVERSION_PILOT', 'UOFS', 'DROP_OFF']; -const friendly = (s) => { - switch (s) { - case 'COS_BIKE_DIVERSION_PILOT': - return 'City of Saskatoon Bike Diversion Pilot'; - case 'UOFS': - return 'University of Saskatchewan'; - case 'DROP_OFF': - return 'Drop Off'; - default: - return undefined; - } -}; - -const sourceMenuItems = sources.map(s => - , -); - -const renderTextField = ({ input, meta: { touched, error }, ...custom }) => ( - -); - -const renderCheckbox = ({ input, meta, label, ...custom }) => ( - -); - -const renderSelectField = ({ input, label, meta: { touched, error }, children, ...custom }) => ( - input.onChange(value)} - children={children} - {...custom} - /> -); const validate = (values) => { const errors = {}; diff --git a/bikeshop_project/assets/js/bikes/components/BikeForm/utils.jsx b/bikeshop_project/assets/js/bikes/components/BikeForm/utils.jsx new file mode 100644 index 0000000..a89ccc9 --- /dev/null +++ b/bikeshop_project/assets/js/bikes/components/BikeForm/utils.jsx @@ -0,0 +1,51 @@ +import React from 'react'; +import Checkbox from 'material-ui/Checkbox'; +import MenuItem from 'material-ui/MenuItem'; +import SelectField from 'material-ui/SelectField'; +import TextField from 'material-ui/TextField'; + +const sources = ['COS_BIKE_DIVERSION_PILOT', 'UOFS', 'DROP_OFF']; + +const friendly = (s) => { + switch (s) { + case 'COS_BIKE_DIVERSION_PILOT': + return 'City of Saskatoon Bike Diversion Pilot'; + case 'UOFS': + return 'University of Saskatchewan'; + case 'DROP_OFF': + return 'Drop Off'; + default: + return undefined; + } +}; + +const sourceMenuItems = sources.map(s => + , +); + +export const renderTextField = ({ input, meta: { touched, error }, ...custom }) => ( + +); + +export const renderCheckbox = ({ input, meta, label, ...custom }) => ( + +); + +export const renderSelectField = ({ input, label, meta: { touched, error }, children, ...custom }) => ( + input.onChange(value)} + children={children} + {...custom} + /> +); \ No newline at end of file